
    ;eP\                       d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZmZmZmZ ddlmZmZmZmZmZ ddlmZ ddlmZ ddlmZ ddlZddlZddlZej        dk    r ed	            ed
dg          Z ed
dg          Zddl Z! eddg          Z"eej#        d
<    eddg          Z$eej#        d
<   ee"ee$iZ%e!ej#        d
<    ej&        ed          Z'eer4 e(e)                                j*        +                                          nde e(e)                                j*        +                                          iZ,eer8ej-        ej.        ej/        ej0        ej1        ej2        ej3        ej4        ej5        g	ndeej-        ej.        ej/        ej0        ej1        ej2        ej3        ej4        ej5        g	iZ6d Z7ej8        Z8ej9        Z9ej:        Z:ej;        Z;ej<        Z<ej=        Z=ej>        Z>ej?        Z?e8e9e:e;e<e=e>e?gZ@eer&e)                                                                ndee)                                                                iZAd ZBdZCeDdk    rejE        d         ZFneGZFejH        I                    eF          pejJ        ZKeKejL        z   eCz   ejL        z   ZMejH        N                    eM           aOdZP eQed          rdndZR ej&        eRd          ZS ejT        eRd          ZU G d d          ZV G d d          ZWe' G d deWejX                              ZY G d d eWejX                  ZZ G d! d"          Z[e' G d# d$e[ejX                              Z\ G d% d&e[ejX                  Z] G d' d(          Z^e' G d) d*e^ejX                              Z_ G d+ d,e^ejX                  Z` G d- d.          Zae' G d/ d0eaejX                              Zb G d1 d2eaejX                  Zcd3 Zdd4 Ze ejf                     G d5 d6                      Zge' G d7 d8egejX                              Zh G d9 d:egejX                  Zi G d; d<          Zje' G d= d>ejejX                              Zk G d? d@ejejX                  Zl G dA dB          Zme' G dC dDemejX                              Zn G dE dFemejX                  Zo G dG dH          Zpe' G dI dJepejX                              Zq G dK dLepejX                  Zr G dM dN          Zse' G dO dPesejX                              Zt G dQ dResejX                  Zu G dS dT          Zve' G dU dVevejX                              Zw G dW dXevejX                  Zx G dY dZ          Zye' G d[ d\eyejX                              Zz G d] d^eyejX                  Z{ G d_ d`          Z|e' G da dbe|ejX                              Z} G dc dde|ejX                  Z~ G de df          Ze' G dg dheejX                              Z G di djeejX                  ZeUe' G dk dlejX                                          Z G dm dn          Ze' G do dpeejX                              Z G dq dreejX                  Z G ds dtejX                  Z G du dvejX                  Z G dw dxejX                  Ze' G dy dzejX                              Zee' G d{ d|ejX                                          Zd} Zd~ Zd ZdadadadaddZeDdk    rddlZ ej        d          Ze                    dddd           e                    dddd           e                                \  ZZej        r edd           dS er eddeej                   dS  edd           dS dS )ab  
These are the test cases for the Decimal module.

There are two groups of tests, Arithmetic and Behaviour. The former test
the Decimal arithmetic using the tests provided by Mike Cowlishaw. The latter
test the pythonic behaviour according to PEP 327.

Cowlishaw's tests can be downloaded from:

   http://speleotrove.com/decimal/dectest.zip

This test module can be called from command line with one parameter (Arithmetic
or Behaviour) to test each part, or without parameter to test both parts. If
you're working through IDLE, you can import this test module and call test()
with the corresponding argument.
    N)is_resource_enabledrequires_IEEE_754requires_docstringsrequires_legacy_unicode_capicheck_sanitizer)
TestFailedrun_with_localecpython_onlydarwin_malloc_err_warningis_emscripten)import_fresh_module)threading_helper)warnings_helperdarwintest_decimaldecimal_decimal)fresh)blocked	fractionsztest requires C versionc                     t          ||          |                     t          fdD                                  d S )Nc              3   B   K   | ]}|v r|         n|          V  d S N ).0sdexpecteds     (/usr/lib/python3.11/test/test_decimal.py	<genexpr>z!assert_signals.<locals>.<genexpr>U   s9      FFqqH}}qttad(FFFFFF    )getattr
assertTrueall)clscontextattrr   r   s      `@r   assert_signalsr(   S   sK    ANN3FFFFFAFFFFFGGGGGr!   c                     | sd S |                      dt          t                              t          |          d                    }|                     |           d S )N	   r   )precroundingtraps)ContextROUND_HALF_EVENdictfromkeysSignals
setcontext)mDefaultTestContexts     r   initr6   l   sY    fft}}WQZ/K/K #   LL#$$$$$r!   decimaltestdata__main__F
DecClampedTz.test requires build with -DEXTRA_FUNCTIONALITYztest requires regular buildc                   Z    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )IBMTestCasesz?Class which tests the Decimal class against the IBM test cases.c                 F   | j                                         | _        | j                                         | _        dg| _        t          g d          | _        | j         t          k    r| j                            d           | j                            d           | j                            d           | j                            d           | j                            d           | j                            d           | j                            d	           | j                            d
           | j	        | j
        | j        | j        | j        d| _        i ddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-i d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdS| _        t           t"          t$          t&          t(          t*          t,          t.          dT| _        | j         j        | j         j        | j         j        | j         j        | j         j        | j         j        | j         j        | j         j        | j         j        | j         j        | j         j        | j         j         dU| _!        dV| _"        d S )WN#)scbx164scbx165expx901expx902expx903expx905lnx901lnx902lnx903lnx905logx901logx902logx903logx905powx1183powx1184powx4001powx4002powx4003powx4005powx4008powx4010powx4012powx4014pwsx803pwsx805powx4302powx4303powx4342powx4343pwmx325pwmx326)	precisionr,   maxexponentminexponentclampandlogical_andapply_applyclassnumber_class
comparesigcompare_signalcomparetotalcompare_totalcomparetotmagcompare_total_magcopycopy_decimalcopyabscopy_abs
copynegatecopy_negatecopysign	copy_sign	divideint
divide_intinvertlogical_invertiscanonicalis_canonicalisfinite	is_finite
isinfiniteis_infiniteisnanis_nanisnormal	is_normalisqnanis_qnanissigned	is_signedissnanis_snanissubnormalis_subnormaliszerois_zeromaxmagmax_magminmagmin_mag	nextminus
next_minusnextplus	next_plus
nexttowardnext_towardor
logical_orreduce	normalizeremaindernearremainder_nearsamequantumsame_quantum
squarerootsqrttoengto_eng_string
tointegralto_integral_valueto_integral_exactto_sci_stringlogical_xor)tointegralxtoscixor)ceilingdownfloor	half_down	half_evenhalf_upup05up)clampedconversion_syntaxdivision_by_zerodivision_impossibledivision_undefinedinexactinvalid_contextinvalid_operationoverflowrounded	subnormal	underflow)r{   r}   r   r   r   r   r   r   r   r   r   )#r   r.   r&   readcontextignore_listsetskipped_test_idsCaddchange_precisionchange_rounding_methodchange_max_exponentchange_min_exponentchange_clamp
ChangeDictNameAdapterROUND_CEILING
ROUND_DOWNROUND_FLOORROUND_HALF_DOWNr/   ROUND_HALF_UPROUND_UP
ROUND_05UPRoundingDictClampedInvalidOperationDivisionByZeroInexactOverflowRounded	Subnormal	Underflow
ErrorNamesLogicalFunctionsselfs    r   setUpzIBMTestCases.setUp   s   |++--<//115 !$ "% "% "% "! "!H <1!%%i000!%%i000!%%j111!%%j111!%%j111!%%j111!%%i000!%%i000 *.)>(,(C+/+C+/+C%)%6	8 8$1E- $1#H$1#N$1 ))9$1 +?	$1
 ,,?$1 #>$1 &j$1 )$1 '{$1 ($1 %%5$1 *.$1 '{$1 )$1 $H$1  '{!$1 $1" %Y#$1$ '{%$1& %Y'$1( *.)$1* %Y+$1, %Y-$1. %Y/$10 (1$12 '{3$14 )5$16 !7$18 %[9$1: ,,<;$1< *.=$1> )?$1@ $OA$1B ))<C$1 $1D +>$3"/I$1 $1 $1N *7&0'2+:+:)6$,&02 2 (,|';151N040K37<3P26,2O'+|';/3|/L151N(,(='+|';)-)?)-)?A A
!1r!   c                 H   | j         t          k    rx| j         j        dk    rh| j                            d           | j                            d           | j                            d           | j                            |          S | j                             ||          S )a2  Work around the limitations of the 32-bit _decimal version. The
           guaranteed maximum values for prec, Emax etc. are 425000000,
           but higher values usually work, except for rare corner cases.
           In particular, all of the IBM tests pass with maximum values
           of 1070000000.@Ti?i9)	r   r   MAX_EMAXr   _unsafe_setprec_unsafe_setemax_unsafe_setemincreate_decimalDecimal)r   vr&   s      r   read_unlimitedzIBMTestCases.read_unlimited  s     <1!6)!C!C,,Z888,,Z888,,[999#221555<''7333r!   c                    t           rt          j        t          |d          5 }|D ]}|                    dd                              dd          }	 |                     |          }C# | j        j        $ r2}|                     d|j	        j
        z   dz   |z              Y d }~d }~ww xY w	 d d d            d S # 1 swxY w Y   d S )Nutf-8)encodingz
 
zException "z" raised on line )skip_expectedunittestSkipTestopenreplace	eval_liner   DecimalExceptionfail	__class____name__)r   fileflinet	exceptions         r   	eval_filezIBMTestCases.eval_file'  sM    	$##$))) 	eQ e e||FB//77bAAet,,AA|4 e e eIImI,?,HHK^^_ccddddddddee	e 	e 	e 	e 	e 	e 	e 	e 	e 	e 	e 	e 	e 	e 	e 	e 	e 	es;   /B=A+*B=+B,:(B'"B='B,,B==CCc                 P   |                     d          dk    r|d d         dk    r{|                    d          sf|                    d          d         dz   |                    d          d                             d          d         z                                   }n-|                    d          d                                         }| j        D ]}|                     |          dk    r d S |sd S d|v r|                     |          S |                     |          S )	Nz -> r      --z  --->   :)find
startswithsplitstripr   eval_directiveeval_equation)r   r   ignores      r   r   zIBMTestCases.eval_line6  s   66&>>Q1RaR5D==f9M9M=q!D(q!''--a0127%'' A a &&((A& 	 	Fvvf~~"" #  	)FAXX&&q)))%%a(((r!   c                    d |                     d          D             \  }}|dk    r| j        |         }n!	 t          |          }n# t          $ r Y nw xY w| j                            |d           } ||           d S )Nc              3   b   K   | ]*}|                                                                 V  +d S r   )r
  lowerr   xs     r   r    z.IBMTestCases.eval_directive.<locals>.<genexpr>I  s4      @@a		))@@@@@@r!   r  r,   c                      d S r   r   )argss    r   <lambda>z-IBMTestCases.eval_directive.<locals>.<lambda>R  s    $ r!   )r	  r   int
ValueErrorr   get)r   r   functvalues       r   r  zIBMTestCases.eval_directiveH  s    @@1773<<@@@uJ%e,EEE

    ##E,>,>@@es   A 
AAc                 n    t           st          j                    dk     rd S  j                                         	 |                    d          }|d                                                                         }|d         }t          rt          d|d           |d                                         }|dd          }|d                                                                         }|d         }|dd          }n'# t          t          t          f$ r  j        j        w xY wd	 }	| j        v rd S  j                            ||          }
|
d
k    rd S t#           j        |
          }g }d}d} fd|D             t$           j                 D ]}d j        j        |<   D ]}d j        j        |<   t)          |          D ]D\  }}|                    d          dz  dk    rd|z
  }|r	|dz   |z   }2||z   }d} |	|          }|
dv rt,          rD ]}d j        j        |<   	  | j                            |                                          d|d|           nG# |$ r Y n@t$           j                 $ r)}                     d|d|d|d           Y d }~nd }~ww xY wd j        j        |<    j                            |          }n                     | j                  }|                    |           F |	|          }t,          rK|
dvrFD ]}d j        j        |<   	  ||                       d|d|           nG# |$ r Y n@t$           j                 $ r)}                     d|d|d|d           Y d }~nd }~ww xY wd j        j        |<   fdt6           j                 D             }|D ]}d j        j        |<   	  ||                       d|d|           3# |$ r Y :t$           j                 $ r5}                     dt9          |          d|d|           Y d }~~d }~ww xY w|D ]}d j        j        |<   t          rt          d j                   	 t;           ||           }|
 j        v r)t;          t?          tA          |                              }nN# t$           j                 $ r%}                     d|d|           Y d }~nd }~w t          d|            xY w !                                }|"                    tF                     "                    tF                      $                    ||d|z   dz   |z               $                    |d|z   dz   t;          |          z              d S )Ng?r  r   zTest  )endr  r  c                    |                      dd                               dd          } |                      dd                               dd          } |                      dd                               dd          } | S )Nz''SingleQuotez""DoubleQuote'r   ")r   )vals    r   	FixQuotesz-IBMTestCases.eval_equation.<locals>.FixQuotesi  sp    ++dM22::4OOC++c2&&..sB77C++mS1199-MMCJr!   rescaler   c                 N    g | ]!}j         |                                         "S r   )r   r  )r   r  r   s     r   
<listcomp>z.IBMTestCases.eval_equation.<locals>.<listcomp>y  s(    JJJ!4?177995JJJr!   r!  )r   r   zDid not raise z in zRaised z when z	 disabledc                     g | ]}|v |	S r   r   )r   etheirexceptionss     r   r'  z.IBMTestCases.eval_equation.<locals>.<listcomp>  s#    ^^^AoI]I]aI]I]I]r!   z; expected r  zERROR:keyzIncorrect answer for z -- got zIncorrect flags set in )%TEST_ALLrandomr&   clear_flagsr	  r
  DEBUGprintr  	TypeErrorAttributeError
IndexErrorr   r   r   r   r  r"   r2   r-   	enumeratecountEXTENDEDERRORTESTr   r   r   appendOrderedSignalstypestrr   r  evalgetexceptionssortreprassertEqual)r   r   SidesLidr  valstempans
exceptionsr$  fnamevalsconglomeratequoter   ir#  r   errorr)  ordered_errorsresultmyexceptionsr*  s   `                      @r   r  zIBMTestCases.eval_equationU  s[    	FMOOd22F  """	0GGDMMEa  &&((A1B ,grs++++aDJJLLEuHa  &&((AA$C122JJ>:6 	0 	0 	0,//	0	 	 	 &&&F $$UE22IFe,,JJJJzJJJ . 	. 	.I,-DLy))( 	. 	.I,-DLy)))) 	 	FAsyy~~!Q&&E	 "+c1C7"S(!	#A:::$ 6!0 6 645*51M!E$,"="=a"@"@AAA !III%%%&KLLLL  % ! ! ! D&t|4 5 5 5 III'(qq!!!UUU'4 5 5 5 5 5 5 5 55
 56*511L//22''4<88KKNNNNinn 	..P!P!P( . .,-"5)EE4LL III%%%CDDDD    Dt|, - - -III qq!!!UUU, - - - - - - - --
 -."5)) _^^^)E^^^N' 
E 
E,-"5)EE4LL III%%%CDDDD    Dt|, 3 3 3III#Awwww552 3 3 3 3 3 3 3 33 ( . .,-"5))  	&$%%%	&&F---Sf..//t|$ 	6 	6 	6III555!!455555555	(A))++d###&&&014zAFJ	L 	L 	L 	'!+j83|;L;LL	N 	N 	N 	N 	Ns   CD $D&-#I,,J03J0J++J0<MN!$N!8NN!&PQQ"+QQAS T%TTc                 @      fdt            j                 D             S )Nc                 8    g | ]}j         j        |         |S r   )r&   flags)r   r)  r   s     r   r'  z.IBMTestCases.getexceptions.<locals>.<listcomp>  s(    JJJaDL4Fq4IJJJJr!   )r2   r   r   s   `r   r=  zIBMTestCases.getexceptions  s$    JJJJ74<0JJJJr!   c                     | j         t          k    r,| j         j        dk    r| j                            |           d S || j        _        d S Nr   )r   r   MAX_PRECr&   r   r+   )r   r+   s     r   r   zIBMTestCases.change_precision  sJ    <1!6)!C!CL((..... $DLr!   c                     || j         _        d S r   )r&   r,   )r   r,   s     r   r   z#IBMTestCases.change_rounding_method  s     (r!   c                     | j         t          k    r,| j         j        dk    r| j                            |           d S || j        _        d S rT  )r   r   rU  r&   r   Eminr   exps     r   r   z IBMTestCases.change_min_exponent  J    <1!6)!C!CL((----- #DLr!   c                     | j         t          k    r,| j         j        dk    r| j                            |           d S || j        _        d S rT  )r   r   rU  r&   r   EmaxrY  s     r   r   z IBMTestCases.change_max_exponent  r[  r!   c                     || j         _        d S r   )r&   ra   )r   ra   s     r   r   zIBMTestCases.change_clamp  s    "r!   N)r   
__module____qualname____doc__r   r   r   r   r  r  r=  r   r   r   r   r   r   r!   r   r;   r;      s        IIK1 K1 K1Z4 4 4e e e) ) )$  ~N ~N ~N@K K K% % %
) ) )$ $ $
$ $ $
# # # # #r!   r;   c                       e Zd ZdZd Zd Zd Zd Zee	 e
j        e          d                                     Zd Zd	 Zd
 Zd Zed             Zd Zd Zd ZdS )ExplicitConstructionTestz6Unit tests for Explicit Construction cases of Decimal.c                 l    | j         j        }|                      |             |d                     d S )N0r   r   r@  r   r   s     r   test_explicit_emptyz,ExplicitConstructionTest.test_explicit_empty  s6    ,&GGCLL11111r!   c                 V    | j         j        }|                     t          |d            d S r   )r   r   assertRaisesr2  rg  s     r   test_explicit_from_Nonez0ExplicitConstructionTest.test_explicit_from_None  s*    ,&)Wd33333r!   c           	      p   | j         j        } |d          }|                     t          |          d            |d          }|                     t          |          d            |d          }|                     t          |          d            |d          }|                     t          |          d           t	          dd	          D ]`}d
D ][}t	          dd          D ]H}|d|z  |z   z  } ||          }|                     t          |          t          |                     I\ad S )N-   45{e	500000123-45r   re      r     r  )r   r   r@  r;  range)r   r   r   nsignr  rK  s          r   test_explicit_from_intz/ExplicitConstructionTest.test_explicit_from_int  sQ   ,& GBKKQ&&& GIQ--- GCLLQ''' GAJJQ%%% q" 	5 	5A 5 5r1 5 5A1q)A

A$$SVVSVV444455	5 	5r!   c           
         | j         j        }| j         j        }| j         j        }|                     t           |d                    d           |                     t           |d                    d           |                     t           |d                    d           |                     t           |d                    d           |                     t           |d                    d           |                     t           |d                    d	           |                     t           |d
                    d           |                     t           |d                    d           |                     t           |d                    d           |                     t           |d                    d           dD ]9}dD ]4}|                     t           ||dz   |z                       d           5: |            5 }d|j        |<   |                     ||d           |                     t          |ddd           |                     ||d           |                     ||d           |                     ||d           |                     ||d           |                     ||d           |                     ||d           d d d            d S # 1 swxY w Y   d S )Nr   NaNrn  45.3445e2z4.5E+3uglyz1.3E4 
z1.3E+4z  -7.89z-7.89z  3.45679  z3.45679z	1_3.3e4_0z1.33E+411_0_0_01000)r   r      u    z	9.311E+28Txyz1234r  yu   1 2 3u    1 2 r  u     z12 3z1_2_ 3)	r   r   r   localcontextr@  r;  r-   rj  r2  )r   r   r   r  leadtrailcs          r   test_explicit_from_stringz2ExplicitConstructionTest.test_explicit_from_string  s~   ,&<8|0 	WWR[[))5111 	WWT]]++T222 	WWW--..888 	WWV__--x888 	WWV__--u555 	WWZ00118<<<WWY//00':::WW]3344i@@@ 	WW[1122J???WWY//00&999 2 	. 	.D6 . .  WWTK-?%-G%H%H!I!I!,. . . .. \^^ 	Hq(,AG$%.???i&#sCCC .9JKKK.9OPPP .BBB.HHH .EEE .GGG'	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	Hs   #C
K::K>K>categoryc                 F   dd l }| j        j        }| j                                        }|                    d          }|                     t           ||                    d           |                     t          |                    |                    d           d S )Nr   9.999999)	_testcapir   r   r.   unicode_legacy_stringr@  r;  r   )r   r  r   r&   r   s        r   test_from_legacy_stringsz1ExplicitConstructionTest.test_from_legacy_stringsM  s     	,&,&&((++J77WWQZZ*555W33A6677DDDDDr!   c                    | j         j        } |d          }|                     t          |          d            |d          }|                     t          |          d            |d          }|                     t          |          d            |d          }|                     t          |          d            |d	          }|                     t          |          d
           |                     t
          |d           |                     t
          |d           |                     t
          |d           |                     t
          | |d          ddf           |                     t
          |d           |                     t
          |d           |                     t
          |d           |                     t
          |d           |                     t
          |d           |                     t
          |d           |                     t
          |d           |                     t
          |d           d S )Nr   r   r   re  r  )   rw  r   rr  r   r  rw     r  r~  r  	r  r  r  r*   r  r  rw  r  r  -4.34913534E-17)r   r   FInfinity)r  r  r  r  r*   r  )   r  r  )        r  r  r  r  r  )r  r  zwrong!)r  r  r  )r  r  1)r  r  r  )r  )r  r  r  Nr  r  )r  )r  r  r*   r  r  )r  )r  
   r  r*   r  r  )r  )r  r  r  ar  r  )r   r   r@  r;  rj  r  r   r   r   s      r   test_explicit_from_tuplesz2ExplicitConstructionTest.test_explicit_from_tuplesY  s7   ,& G\##Q%%% G^%%Q''' G*,,Q))) G:<<Q!2333 G\##Q,,, 	*g/CEEE 	*g/FHHH*g/GIII*g

OQ/OPPP 	*g/MOOO*g/GIII*g/HJJJ 	*g}>>>*g/IKKK*g/GIII*g/GIII*g/HJJJJJr!   c                    | j         j        } |ddgdg          }|                     t          |          d            |dg ddg          }|                     t          |          d            |g d          }|                     t          |          d            |dg ddf          }|                     t          |          d           d S )Nr   re  r  r  r  r  r  r   r   r@  r;  r  s      r   test_explicit_from_listz0ExplicitConstructionTest.test_explicit_from_list  s    ,&GQQK  Q%%%GQ333S9::Q!2333G999::Q!2333GQ333S9::Q!233333r!   c                 n   | j         j        }|                     t           |d                    d           |                     t           |d                    d           |                      |d           |d                     |                      |d           |d                     d S )Nr   Fr  T)r   r   assertIsboolr@  rg  s     r   test_explicit_from_boolz0ExplicitConstructionTest.test_explicit_from_bool  s    ,&d771::&&...d771::&&---444

33333r!   c                    | j         j        } |d          } ||          }|                     t          |          d            |d          } ||          }|                     t          |          d            |d          } ||          }|                     t          |          d            |d          } ||          }|                     t          |          d           d S )	Nrm  rn  ro  rp  rq  rr  r   re  r  r   r   r   r)  s       r   test_explicit_from_Decimalz3ExplicitConstructionTest.test_explicit_from_Decimal  s    ,& GBKKGAJJQ&&& GIGAJJQ--- GCLLGAJJQ''' GAJJGAJJQ%%%%%r!   c           	      ~   | j         j        } |d          }|                     t          |          |           |                     t	          |          d           |                      |t          d                                                               |                      |t          d                                                               |                      |t          d                                                               |                     t	           |t          d                              t	           |d                               |                     t	           |t          d                              t	           |d                               |                     t	           |t          d                              t	           |d                               |                     t	           |t          d	                              t	           |d
                               t          d          D ]\}t          j        d          t          j
                    dz  dz
  z  }|                     |t           ||                               ]d S )N皙?90.1000000000000000055511151231257827021181583404541015625naninf-infr}  r  	-Infinity-0.0-0   {Gz?       @      ?)r   r   r@  r:  r;  r#   floatr   r   rx  r.  expovariate)r   r   rrK  r  s        r   test_explicit_from_floatz1ExplicitConstructionTest.test_explicit_from_float  sl    ,&GCLLa'***QK	M 	M 	Me--5577888e--99;;<<<f..::<<===WWU5\\2233WWU^^,,	. 	. 	.WWU5\\2233WWZ0011	3 	3 	3WWU6]]3344WW[1122	4 	4 	4WWU6]]3344WWT]]++	- 	- 	-s 	3 	3A"4((FMOOc,AC,GHAQggajj 1 12222	3 	3r!   c           	         | j         j        }| j         j        }| j         j        }t	          j        | j                                                   }d|_         |            }|                     t          |          d           |	                                }|                     t          |          d           | 
                    t          |j	        d            |	                    d          }|                     ||           |                     |	                    d          |	                    d                      |d          }|                     t          |          d           |	                    d          }|                     t          |          d           |                     t          |	                    d                    d	            |d
          }|                     t          |          d           |	                    d
          }|                     t          |          d            |d          } ||          }|                     t          |          d           |	                    |          }|                     t          |          d           d|_        d|j        |<   dD ]]}|	                    |          }|                     t          ||                     |                     t!          |          |           ^d|_        d|j        |<   | 
                    ||j	        d           d|_        |                     t          |	                    d                    d           |                     t          |	                    d                    d           |                     t          |	                    d                    d           |                     t          |	                    d                    d           | 
                    ||j	        d           | 
                    t"          |j	        d           | 
                    t          |j	        dd           | 
                    ||j	        d           | 
                    ||j	        d           d|_        | 
                    ||j	        d            | 
                    ||j	         |d                      d!|j        |<   |                     t          |	                    d                     d	           |                     |j        |                    d!|j        |<   |                     t          |	                     |d                               d	           |                     |j        |                    d S )"Nr  re    in  z457E+2456789z4.57E+5z3.14
r}  r  r  z	-4.35E-17ro  rp  z5.00E+8   T)	l        l         l    i   r   l                          z0E-017z0E-17rn  -Infr  NaN123r  )r  r  r  r  5678z 123412_34NaN12345F)r   r   r   r   rn   
getcontextr+   r@  r;  r   rj  r2  assertIsInstancer-   r#   
isinstancer  r  rR  )r   r   r   r   ncr   prevdecr   s           r   $test_explicit_context_create_decimalz=ExplicitConstructionTest.test_explicit_context_create_decimal  sd   ,&<8,&Yt|..0011 GIIQ%%%Q%%% 	)R%6=== c""a)))**511**844	6 	6 	6 GHQ***h''Q+++ 	R..x88995AAA G:<<Q!2333DFFQ--- ')$$GGQ---g&&Q+++ %)!"3 	( 	(A!!!$$AOOJq'22333SVVQ'''' '2#4d;;; R..x88997CCCR..t4455t<<<R..v6677EEER..x88998DDD 	*B,=uEEE*b&7III)R%6GGG*B,=wGGG*B,=wGGG *B,=zJJJ*B,=!'*--	/ 	/ 	/ &+!"R..z::;;UCCC!12333%*!"R..wwz/B/BCCDDeLLL!1233333r!   c           	         | j         j        }| j                                         }|                    d          }|                     t          |          |           |                     t          |          d           |                     |                    t          d                    	                                           |                     |                    t          d                    
                                           |                     |                    t          d                    
                                           |                     t          |                    t          d                              t          |                    d                               |                     t          |                    t          d                              t          |                    d                               |                     t          |                    t          d                              t          |                    d                               |                     t          |                    t          d	                              t          |                    d
                               d|_        t          d          D ]f}t          j        d          t          j                    dz  dz
  z  }|                     |t          |                    |                               gd S )Nr  z0.1000000000000000055511151231r  r  r  r}  r  r  r  r  d   r  r  r  r  )r   r   r.   r   r@  r:  r;  r#   r  r   r   r+   rx  r.  r  )r   r   r  r  rK  r  s         r   'test_explicit_context_create_from_floatz@ExplicitConstructionTest.test_explicit_context_create_from_float#  s   ,&\!!##c""a'***Q!ABBB))%,,77??AABBB))%,,77CCEEFFF))%--88DDFFGGGR..uU||<<==R..u5566	8 	8 	8R..uU||<<==R..z::;;	= 	= 	=R..uV}}==>>R..{;;<<	> 	> 	>R..uV}}==>>R..t4455	7 	7 	7s 	= 	=A"4((FMOOc,AC,GHAQb&7&7&:&: ; ;<<<<	= 	=r!   c                     | j         j        }dddd}|                                D ]1\  }}|                     t	           ||                    |           2d S )Nr  z	0.0000372z-NaN2400)u   １u   ٠.٠٣٧٢e-٣u   -nan౨౪౦౦)r   r   itemsr@  r;  )r   r   test_valuesinputr   s        r   test_unicode_digitsz,ExplicitConstructionTest.test_unicode_digits;  sw    ,& 8C-7 
  +0022 	< 	<OE8S00(;;;;	< 	<r!   N)r   r_  r`  ra  rh  rk  r{  r  r
   r   r   ignore_warningsDeprecationWarningr  r  r  r  r  r   r  r  r  r  r   r!   r   rc  rc    s-       @@2 2 24 4 45 5 566H 6H 6Hp !$_$.@AAAE E BA "! \E)K )K )KV4 4 44 4 4& & &. 3 3 3.W4 W4 W4r= = =0	< 	< 	< 	< 	<r!   rc  c                       e Zd ZeZdS )CExplicitConstructionTestNr   r_  r`  r   r   r   r!   r   r  r  F          GGGr!   r  c                       e Zd ZeZdS )PyExplicitConstructionTestNr   r_  r`  Pr   r   r!   r   r  r  I          GGGr!   r  c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	ImplicitConstructionTestz6Unit tests for Implicit Construction cases of Decimal.c                 z    | j         j        }|                     t          t          dt                                 d S )NzDecimal(5) + Noner   r   rj  r2  r<  localsrg  s     r   test_implicit_from_Nonez0ImplicitConstructionTest.test_implicit_from_NoneO  s1    ,&)T+>IIIIIr!   c                     | j         j        }|                     t           |d          dz             d           |                      |d          dz    |d                     d S )Nrw  rm  50l   2}r r  rg  s     r   test_implicit_from_intz/ImplicitConstructionTest.test_implicit_from_intS  sk    ,& 	WWQZZ"_--t444l2GGL4I4IJJJJJr!   c                 z    | j         j        }|                     t          t          dt                                 d S )NzDecimal(5) + "3"r  rg  s     r   test_implicit_from_stringz2ImplicitConstructionTest.test_implicit_from_string[  1    ,&)T+=vxxHHHHHr!   c                 z    | j         j        }|                     t          t          dt                                 d S )NzDecimal(5) + 2.2r  rg  s     r   test_implicit_from_floatz1ImplicitConstructionTest.test_implicit_from_float_  r  r!   c                     | j         j        }|                      |d           |d          z    |d                     d S )Nrw  rm  2   rf  rg  s     r   test_implicit_from_Decimalz3ImplicitConstructionTest.test_implicit_from_Decimalc  sE    ,&ggbkk1772;;?????r!   c                    | j         j        } G d d          }|                     t           |             |d                    d           |                     t           |d           |                      d           |                     t	          d          d           |                     t	          d          d	           |                     t	          d
          d           |                     t	          d          d           |                     t	          d          d           |                     t	          d          d           g d}|D ]\  }t          |fd           t          |fd           |                     t	          d|z   dz             dz   dz              |                     t	          d|z   dz             dz   dz              d S )Nc                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
,ImplicitConstructionTest.test_rop.<locals>.Ec                 &    dt          |          z   S )Nzdivmod r;  r   others     r   
__divmod__z7ImplicitConstructionTest.test_rop.<locals>.E.__divmod__l  s     3u::--r!   c                 &    t          |          dz   S )Nz rdivmodr  r  s     r   __rdivmod__z8ImplicitConstructionTest.test_rop.<locals>.E.__rdivmod__n  s    5zzJ..r!   c                 &    dt          |          z   S )Nzlt r  r  s     r   __lt__z3ImplicitConstructionTest.test_rop.<locals>.E.__lt__p      s5zz))r!   c                 &    dt          |          z   S )Nzgt r  r  s     r   __gt__z3ImplicitConstructionTest.test_rop.<locals>.E.__gt__r  r	  r!   c                 &    dt          |          z   S )Nzle r  r  s     r   __le__z3ImplicitConstructionTest.test_rop.<locals>.E.__le__t  r	  r!   c                 &    dt          |          z   S )Nzge r  r  s     r   __ge__z3ImplicitConstructionTest.test_rop.<locals>.E.__ge__v  r	  r!   c                 &    dt          |          z   S )Nzeq r  r  s     r   __eq__z3ImplicitConstructionTest.test_rop.<locals>.E.__eq__x  r	  r!   c                 &    dt          |          z   S )Nzne r  r  s     r   __ne__z3ImplicitConstructionTest.test_rop.<locals>.E.__ne__z  r	  r!   N)r   r_  r`  r  r  r  r  r  r  r  r  r   r!   r   Er  k  s        . . ./ / /* * ** * ** * ** * ** * ** * * * *r!   r  r  z	divmod 10z
10 rdivmodzDecimal(10) < E()zgt 10zDecimal(10) > E()zlt 10zDecimal(10) <= E()zge 10zDecimal(10) >= E()zle 10zDecimal(10) == E()zeq 10zDecimal(10) != E()zne 10))+__add____radd__)-__sub____rsub__)*__mul____rmul__)/__truediv____rtruediv__)%__mod____rmod__)z//__floordiv____rfloordiv__)z**__pow____rpow__c                 .    dz   t          |          z   S Nr;  r  )r   r  lops     r   r  z3ImplicitConstructionTest.test_rop.<locals>.<lambda>  s    c%jj0H r!   c                 .    t          |          z   dz   S r)  r  )r   r  rops     r   r  z3ImplicitConstructionTest.test_rop.<locals>.<lambda>  s    E

S0@50H r!   zE()zDecimal(10)r;  10)r   r   r@  divmodr<  setattr)r   r   r  oplistsymr*  r,  s        @@r   test_ropz!ImplicitConstructionTest.test_ropg  s,   ,&	* 	* 	* 	* 	* 	* 	* 	*$ 	WWR[[11;???QQSS11<@@@122G<<<122G<<<233W===233W===233W===233W===
 
 
 $ 	1 	1MCcAsHHHHIIIAsHHHHIIIT%#+"=>>"S[4/1 1 1T-#"5"=>>!CZ%/1 1 1 1	1 	1r!   N)
r   r_  r`  ra  r  r  r  r  r  r2  r   r!   r   r  r  L  s        @@J J JK K KI I II I I@ @ @01 01 01 01 01r!   r  c                       e Zd ZeZdS )CImplicitConstructionTestNr  r   r!   r   r4  r4    r  r!   r4  c                       e Zd ZeZdS )PyImplicitConstructionTestNr  r   r!   r   r6  r6    r  r!   r6  c                   Z    e Zd ZdZd Zd Zd Zd Z edd          d             Z	d	 Z
d
S )
FormatTestz#Unit tests for the format function.c                     | j         j        }g d}|D ]3\  }}}|                     t           ||          |          |           4|                     t
           |d          j        d           d S )N))r)  0E-15z0e-15)r)  z2.3E-15z2.3e-15)r)  z2.30E+2z2.30e+2)r)  z2.30000E-15z2.30000e-15)r)  z1.23456789123456789e40z1.23456789123456789e+40)r)  1.5z1.5e+0)r)  z0.15z1.5e-1)r)  z0.015z1.5e-2)r)  z0.0000000000015z1.5e-12)r)  z15.0z1.50e+1)r)  -15z-1.5e+1)r)  re  z0e+0)r)  0E10e+1)r)  0.0z0e-1)r)  0.000e-2).6er:  z0.000000e-9)rB  re  z0.000000e+6)rB  r  z9.999999e+0)rB  z	9.9999999z1.000000e+1)rB  z-1.23e5z-1.230000e+5)rB  z1.23456789e-3z1.234568e-3)r   re  re  )r   r?  r?  )r   0E-2r@  )r   z0.00E-8z0.0000000000)r   r=  re  )r   z3.2E132)r   z3.2E2320)r   z3.20E2rE  )r   z3.200E2z320.0)r   z3.2E-6z	0.0000032).6fr:  0.000000)rF  r=  rG  )rF  re  rG  ).0fre  re  )rH  rA  re  )rH  
3.141592653).1frI  3.1)z.4frI  3.1416)rF  rI  3.141593)z.7frI  	3.1415926)z.8frI  rI  )z.9frI  z3.141592650)gre  re  )rP  r?  r?  )rP  r=  r>  )Gr=  z0E+1)rP  z0E-5z0.00000)rP  z0E-6rG  )rP  z0E-7z0e-7)rP  z-0E2z-0e+2).0grI  rJ  )z.0nrI  rJ  )z.1grI  rJ  )z.2grI  rL  )z.5grI  rM  )z.7grI  rN  )z.8grI  rO  )z.9grI  rI  )z.10grI  rI  )r!  r=  0%)r!  0E0rS  )r!  z0E-1rS  )r!  rC  rS  )r!  z0E-3z0.0%)r!  z0E-4z0.00%).3%re  0.000%)rU  0E10rV  )rU  z0E-10rV  )rU  z2.34z234.000%)rU  z1.234567z123.457%).0%1.23z123%)r)  r}  r}  )r   -NaN123rZ  )z+gNaN456z+NaN456)z.3eInfr  )z.16fr  r  )rR  -sNaNr]  )r   1.00r^  )6123   123)z<6r`  z123   )z>6r`  ra  )z^6r`  z 123  )z=+6r`  z+  123)#<10r}  z
NaN#######)rb  z-4.3z
-4.3######)z#<+100.0130z
+0.0130###)z#< 10rc  z
 0.0130###)z@>10r  z
@-Infinity)z#>5r  r  )z?^5r`  z?123?)z%^6r`  z%123%%)z ^6-45.6z-45.6 )z/=10rd  z
-/////45.6)z/=+1045.6z
+/////45.6)z/= 10re  z
 /////45.6)z =10r  z
- Infinity)z ^16r  z   -Infinity    )z >101.2345z
    1.2345)z <10rf  z
1.2345    ),1234567z	1,234,567)rg  123456123,456)rg  1234512,345)rg  r  z1,234)rg  r`  r`  )rg  12rm  )rg  r  r  )rg  re  re  )rg  z-1234567z
-1,234,567)rg  -123456-123,456)z7,ri  rj  )z8,ri   123,456)08,ri  z	0,123,456)z+08,ri  z+123,456)z 08,ri  rp  )rq  rn  ro  )z+09,ri  z
+0,123,456)z07,1234.561,234.56)rq  rr  rs  )z09,rr  z	01,234.56)z010,rr  z
001,234.56)z011,rr  0,001,234.56)z012,rr  rt  )z08,.1fz1234.5z01,234.5)rg  
1.23456789ru  )z,%z
123.456789z12,345.6789%)z,eri  z
1.23456e+5)z,Eri  z
1.23456E+5)rK  r  r  )rK  z-.0r  )rK  -.01r  )z.1f0.r?  )z6.1frx  z   0.0)ry  -1.z  -1.0)rw  -0.r?  )rw  .01r?  )rw  rv  r?  )z.2frx  r@  )r}  r{  r@  )r}  z.001r@  )r}  z-.001r@  )z.1erx  0.0e+1)r~  r{  r  )z.1Erx  0.0E+1)r  r{  r  )zz.2e-0.001z-1.00e-3)zz.2gr  r  )zz.2%r  z-0.10%)zfz-0.0000z0.0000)rw  -00000.000001r?  )rw  -00000.r?  )rw  -.0000000000r?  )r}  r  r@  )r}  r  r@  )r}  r  r@  )rw  z.090.1)rw  z-.09z-0.1) z.0fr{  z 0)+z.0fr{  z+0)-z.0fr{  re  )r  rz  -1)r  rz  r  )r  rz  r  )zz>6.1fr{  zzz-0.0)zz>z6.1fr{  zzzz0.0)zx>z6.1fr{  zxxx0.0)u
   🖤>z6.1fr{  u   🖤🖤🖤0.0)za=-7.0z0.12345zaaaa0.1)z	<^+15.20%r  z<<+Infinity%<<<)z>,%sNaN1234567zsNaN1234567%)z=10.10%r  z
   NaN123%r  s   -020)r   r   r@  formatrj  r2  
__format__)r   r   r  fmtr   rN  s         r   test_formattingzFormatTest.test_formatting  s    ,&G G GP * 	> 	>NCFVGGAJJ44f==== 	)WWQZZ%:GDDDDDr!   c                     | j                                         5 }t          |_        |                     t          | j                             d          d          d           d d d            d S # 1 swxY w Y   d S )Nr  r}  r@  )r   r  r   r,   r@  r  r   r   ctxs     r   +test_negative_zero_format_directed_roundingz6FormatTest.test_negative_zero_format_directed_roundings  s    \&&(( 	$C(CLVDL$8$8$B$BFKK"$ $ $	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s   A	A00A47A4c                 z    |                      t          t          | j                            d          d           d S )NrY  fz)rj  r  r  r   r   r   s    r   test_negative_zero_bad_formatz(FormatTest.test_negative_zero_bad_formaty  s2    *fdl.B.B6.J.JDQQQQQr!   c                 	   	  j         j        		 ddlm} n%# t          $ r                      d           Y nw xY w fd}d?	 fd	}d |g d          d	d
}d	 ||g          dd
}d	 |g d          dd
}d |ddd|g          dd
}d                    d           |g d          d                    d          d
}                      | 	d          |          d                                 | 	d          |          d                                 | 	d          |          d                                 | 	d          |          d                                 |d|          d                                 |d|          d                                 |d|          d                                 |d|          d                                 |d|d          d                                 |d|d          d                                  |d|d          d                                  |d|d          d!                                 |d"|d#          d$                                 |d"|d%          d$                                 |d"|d&          d'                                 |d"|d(          d)                                 |d*|d&          d+                                 |d*|d(          d+                                 |d*|d,          d-                                 |d*|d.          d/                                 |d*|d0          d/                                 |d*|d1          d2                                 |d3|d(          d4                                 |d3|d,          d4                                 |d3|d.          d4                                 |d3|d0          d5                                 |d3|d1          d6                                 |d3|d7          d6                                 |d3|d8          d9                                 |d3|d:          d;                                 | 	d<          |d=          d>           d S )@Nr   CHAR_MAXlocale.CHAR_MAX not availablec                 f    j         t          k    rd                    d | D                       n| S )Nr   c                 ,    g | ]}t          |          S r   chrr  s     r   r'  zCFormatTest.test_n_format.<locals>.make_grouping.<locals>.<listcomp>      000qCFF000r!   )r   r   join)lstr   s    r   make_groupingz/FormatTest.test_n_format.<locals>.make_grouping  s5    59\Q5F5F27700C000111COr!   ry  c                     j         t          k    r |                               ||          S  |                               ||          S )N)_localeconv)r   r   r  )r  overrider  r   r   s      r   get_fmtz)FormatTest.test_n_format.<locals>.get_fmt  sO    |q  wqzz,,S(;;;wqzz,,Sh,GGGr!   .r  r  r   rg  decimal_pointgroupingthousands_sepr   r  &r  r  r  r  s   ¿r   s   ´z12.7z12,7z1-2&7i[z123,456,789	123456789z123 456 789l   c}z123456-78-9012-3z.6nz
1.23457e+8z
1,23457e+8z
1&23457e+8r  03nr  04n05n0123406n00123490  rl  07nz012,34508nz	0,012,34509n010nz
00,012,345i@ z1-2345-6z	01-2345-6z0-01-2345-6011n012nz00-01-2345-6013nz000-01-2345-6-1.5020nu   -0´000´000´000´001¿5Nry  )r   r   localer  ImportErrorskipTestdecoder@  )
r   r  r  r  en_USfr_FRru_RUcrazydotsep_wider   s
   `        @r   test_n_formatzFormatTest.test_n_format|  s   ,&	;''''''' 	; 	; 	;MM9:::::	;	P 	P 	P 	P 	P	H 	H 	H 	H 	H 	H 	H "&yyy11!  "&z22   "%iii00!  "%q!Q&9::!  *0099%iii00)0099  	%88&AAA%88&AAA%88&AAA%88'BBBE22MBBBE22K@@@E22MBBB668JKKKE599<HHHE599<HHHE599<HHHE599<HHH 	ue44f===ue44f===ue44g>>>ue44h???u55x@@@u55x@@@u55yAAAu55{CCCu55{CCCv66EEE66
CCC66
CCC66
CCC66DDD77GGG77GGG77HHH77III 	+vFFH	J 	J 	J 	J 	Js    99LC_ALLps_AFc                    | j         j        }t          j                    d         }t          j                    d         }|dk    r)|                     d                    |d                     |dk    r)|                     d                    |d                     |                     t           |d          d          d	           d S )
Nr  r  u   ٫z5inappropriate decimal point separator ({!a} not {!a})u   ٬z1inappropriate thousands separator ({!a} not {!a})z100000000.123ry  u   100٬000٬000٫123)r   r   r  
localeconvr  r  r@  )r   r   r  r  s       r   &test_wide_char_separator_decimal_pointz1FormatTest.test_wide_char_separator_decimal_point  s     ,&)++O<)++O<H$$MM ,,2F=(,K,KM M MH$$MM ,,2F=(,K,KM M M 	 8 8#>>9	; 	; 	; 	; 	;r!   c                     G d d| j         j                  }|                    d          }|                     | j         j        |j                   |                    d          }|                     | j         j        |j                   d S )Nc                       e Zd Zd ZdS );FormatTest.test_decimal_from_float_argument_type.<locals>.Ac                 .    t          |          | _        d S r   )r:  a_type)r   r  s     r   __init__zDFormatTest.test_decimal_from_float_argument_type.<locals>.A.__init__  s    "1ggr!   Nr   r_  r`  r  r   r!   r   Ar    s#        & & & & &r!   r  g     @E@*   )r   r   
from_floatr@  r  )r   r  r  s      r   %test_decimal_from_float_argument_typez0FormatTest.test_decimal_from_float_argument_type  s    	& 	& 	& 	& 	&$ 	& 	& 	& LL-qx888LL-qx88888r!   N)r   r_  r`  ra  r  r  r  r  r	   r  r  r   r!   r   r8  r8    s        --PE PE PEd$ $ $R R RWJ WJ WJr _Xw''; ; ('; 9 9 9 9 9r!   r8  c                       e Zd ZeZdS )CFormatTestNr  r   r!   r   r  r    r  r!   r  c                       e Zd ZeZdS )PyFormatTestNr  r   r!   r   r  r    r  r!   r  c                   T    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd ZdS )ArithmeticOperatorsTestz:Unit tests for all arithmetic operators, binary and unary.c                    | j         j        } |d          } |d          }|                     ||z    |d                     |                     ||z    |d                     |dz   }|                     | |d                     |                     t          |          t          |                     d|z   }|                     | |d                     |                     t          |          t          |                     ||z  }|                     | |d                     |dz  }|                     | |d                     d S )N-11.122.2z11.1rw  z-6.116.1r   r   r@  r:  r   r   d1d2r  s        r   test_additionz%ArithmeticOperatorsTest.test_addition  s\   ,&WWWV__ 	B000B000 FGGFOO,,,a$r((+++ FGGFOO,,,a$r((+++ 	bWWV__--- 	aWWV__-----r!   c                    | j         j        } |d          } |d          }|                     ||z
   |d                     |                     ||z
   |d                     |dz
  }|                     | |d                     |                     t          |          t          |                     d|z
  }|                     | |d                     |                     t          |          t          |                     ||z  }|                     | |d                     |dz  }|                     | |d                     d S )	Nr  r  z-33.3z33.3rw  z-16.1r  z-38.3r  r  s        r   test_subtractionz(ArithmeticOperatorsTest.test_subtraction  sd   ,&WWWV__ 	B 0 0111B000 FGGG,,---a$r((+++ FGGFOO,,,a$r((+++ 	bWWW--... 	aWWW--.....r!   c                    | j         j        } |d          } |d          }|                     ||z   |d                     |                     ||z   |d                     |dz  }|                     | |d                     |                     t          |          t          |                     d|z  }|                     | |d                     |                     t          |          t          |                     ||z  }|                     | |d                     |dz  }|                     | |d                     d S )N-5rJ  r<  rw  z-25z-75r  r  s        r   test_multiplicationz+ArithmeticOperatorsTest.test_multiplication1  sZ   ,&WT]]WS\\ 	B///B/// FGGENN+++a$r((+++ FGGENN+++a$r((+++ 	bWWU^^,,, 	aWWU^^,,,,,r!   c                    | j         j        } |d          } |d          }|                     ||z   |d                     |                     ||z   |d                     |dz  }|                     | |d                     |                     t          |          t          |                     d|z  }|                     | |d                     |                     t          |          t          |                     ||z  }|                     | |d                     |dz  }|                     | |d                     d S )	Nr  2-2.5z-0.4r  z-1.25z-0.8z-0.625r  r  s        r   test_divisionz%ArithmeticOperatorsTest.test_divisionM  s^   ,&WT]]WS\\ 	B000B000 FGGG,,---a$r((+++ FGGFOO,,,a$r((+++ 	bWWV__--- 	aWWX../////r!   c                    | j         j        } |d          } |d          }|                     ||z   |d                     |                     ||z   |d                     |dz  }|                     | |d                     |                     t          |          t          |                     d|z  }|                     | |d                     |                     t          |          t          |                     ||z  }|                     | |d                     |dz  }|                     | |d                     d S )N5r  re  r  r     r  r  r  s        r   test_floor_divisionz+ArithmeticOperatorsTest.test_floor_divisioni  sZ   ,&WS\\WS\\ 	R...R... !GGGCLL)))a$r((+++ GGGCLL)))a$r((+++ 	r	WWS\\*** 	qWWS\\*****r!   c                    | j         j        } |d          } |d          }|                     ||z   |d                     |                     ||z   |d                     |dz  }|                     | |d                     |                     t          |          t          |                     d|z  }|                     | |d                     |                     t          |          t          |                     ||z  }|                     | |d                     |dz  }|                     | |d	                     d S )
Nr  r  25rD  r  625r  16807390625r  r  s        r   test_poweringz%ArithmeticOperatorsTest.test_powering  s^   ,&WS\\WS\\ 	R///R/// !GGGENN+++a$r((+++ GGGG,,---a$r((+++ 	r	WWT]]+++ 	qWWX../////r!   c                    | j         j        } |d          } |d          }|                     ||z   |d                     |                     ||z   |d                     |dz  }|                     | |d                     |                     t          |          t          |                     d|z  }|                     | |d                     |                     t          |          t          |                     ||z  }|                     | |d                     |dz  }|                     | |d                     d S Nr  r  r  r  r  r  r  s        r   test_modulez#ArithmeticOperatorsTest.test_module  sZ   ,&WS\\WS\\ 	B---B--- FGGCLL)))a$r((+++ FGGCLL)))a$r((+++ 	bWWS\\*** 	aWWS\\*****r!   c                 p   | j         j        } |d          } |d          }t          ||          \  }}|                     | |d                     |                     | |d                     |                     t	          |          t	          |                     |                     t	          |          t	          |                     t          |d          \  }}|                     | |d                     |                     | |d                     |                     t	          |          t	          |                     |                     t	          |          t	          |                     t          d|          \  }}|                     | |d                     |                     | |d                     |                     t	          |          t	          |                     |                     t	          |          t	          |                     d S r  )r   r   r.  r@  r:  )r   r   r  r  pqs         r   test_floor_div_modulez-ArithmeticOperatorsTest.test_floor_div_module  s   ,&WS\\WS\\ BAGGCLL)))GGCLL)))a$r((+++a$r((+++ AAGGCLL)))GGCLL)))a$r((+++a$r((+++ 2AGGCLL)))GGCLL)))a$r((+++a$r((+++++r!   c                 F   | j         j        }|                      |d          
  |d                     |                      |d            |d                     |                     t           |d                    t           |d                               d S )Nrm  rq  )r   r   r@  absrg  s     r   test_unary_operatorsz,ArithmeticOperatorsTest.test_unary_operators  s    ,&''"++wws||444''"++wws||444WWR[[))3wws||+<+<=====r!   c                    | j         j        }| j         j        }| j         j        } |d          } |d          } |d          } |d          }||f||f||f||f||ff}||f||f||f||f||f||f||ff}	t          j        t          j        t          j        t          j        f}
t          j	        t          j
        f} |            5 }d|j        |<   ||	z   D ]^\  }}|
|z   D ]S} |||          }|t          j
        u rdnd}|                     ||d                    ||j        |||                     T_	 d d d            n# 1 swxY w Y    |            5 }d	|j        |<   |D ][\  }}|D ]S} |||          }|t          j
        u rdnd}|                     ||d                    ||j        |||                     T\|	D ]N\  }}|D ]F}|                     |t          j	        ||           |                     |t          j
        ||           GO||	z   D ]"\  }}|
D ]}|                     ||||           #	 d d d            d S # 1 swxY w Y   d S )
Nr}  sNaNr\  r  r   TFz8expected {0!r} for operator.{1}({2!r}, {3!r}); got {4!r}r  )r   r   r   r  operatorltlegtgeeqner-   r  r  r   rj  )r   r   r   r  ry  r   rK  r   
qnan_pairs
snan_pairs	order_opsequality_opsr  r  r  opgotr   s                     r   test_nan_comparisonsz,ArithmeticOperatorsTest.test_nan_comparisons  s    ,&<8|0GENNGFOOGENNGCLLVaVaVaVaV;
VaVaVaVaVaVaVK
Khk8;F	{HK/ \^^ 
	?s*+CI&'"Z/ ? ?1#l2 ? ?B"Q((C')X['8'8tteHMM(C!,,2F$bk1a-> ->? ? ? ???
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? \^^ 	Bs*+CI&'" ? ?1& ? ?B"Q((C')X['8'8tteHMM(C#..4f$bk1a/> />? ? ? ?? # K K1& K KB%%&6QJJJ%%&6QJJJJK #Z/ B B1# B BB%%&6AqAAAABB%	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs&   	A/EE	E	C"I

IIc                 $   | j         j        } |d                               |d                    }|                      |d                              d          |           |                     t
           |d          j        d           d S )Nr  r  -2)r   r   ru   r@  rj  r2  r  s      r   test_copy_signz&ArithmeticOperatorsTest.test_copy_sign  s    ,&GAJJ  ----b111555)WWQZZ%94@@@@@r!   N)r   r_  r`  ra  r  r  r  r  r  r  r  r  r  r  r  r   r!   r   r  r    s        DD. . .8/ / /8- - -80 0 08+ + +80 0 08+ + +8, , ,6> > >8B 8B 8BtA A A A Ar!   r  c                       e Zd ZeZdS )CArithmeticOperatorsTestNr  r   r!   r   r  r     r  r!   r  c                       e Zd ZeZdS )PyArithmeticOperatorsTestNr  r   r!   r   r  r  #  r  r!   r  c           
         | j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        } |d          }	 |d          }
|	|
z  }| j	        
                                 | j                                         |	|
z  } |            5 }|                     |j        |                    |                     ||j        |	d           |                     |j        |                     |            5 }|                     |j        |                    |                     |j        |                    |                     ||j        |	 |d                     |                     |j        |                    ~d d d            n# 1 swxY w Y   |                     |j        |                    ~d d d            n# 1 swxY w Y   |                     | |d                     |                     | |d                      |            }|                     |j        |                    ||||fD ]"}|                     |j        |                    #d S )Nr  r  r   r  0.333333333333333333333333)r   r   r   r   r   r   r   r  r  finish1r   synchrowaitr#   rR  rj  dividecompareassertFalser@  )r%   r   r   r   r   r   r   r  r  r  d3test1test2c2c3c1sigs                    r   thfunc1r-  (  s   k!G{3[/N{#H%Ik!G'J;+L	B	BrEEKOOKrEE	 2rx()))B:::rx/000\^^ 	rNN28G,---NN28N3444-rz2wwvOOONN28$45666	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	!12333               OOE77#?@@AAAOOE77#?@@AAA	BNN28G$%%%N4DD ' '&&&&' 's8   =A(G1%BF9-G19F=	=G1 F=	$G11G58G5c           	         | j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        } |d          }	 |d          }
|	|
z  } |            }d|_	        |	|
z  } |            5 }| 
                    |j        |                    |                     ||j         |d          d           | 
                    |j        |                     ||          5 }| 
                    |j        |                    |                     |j        |                    d|j        |<   |                     ||j         |d          d           | 
                    |j        |                    ~d d d            n# 1 swxY w Y   |                     |j        |                    |                     |j        |                    ~d d d            n# 1 swxY w Y   | j                                         | j                                         |                     | |d                     |                     | |d	                     |                     |j        |                    | 
                    |j        |                    ||||fD ]"}|                     |j        |                    #d S )
Nr  r     1e425000000  Tz1e-425000000r  z0.333333333333333333)r   r   r   r   r   r   r   r  r  r+   r#   rR  rj  multiplyr%  r-   r#  r!  r   finish2r@  )r%   r   r   r   r   r   r   r  r  r  r&  r'  thiscontextr(  r)  r*  r,  s                    r   thfunc2r5  O  s9   k!G{3[/N{#H%Ik!G'J;+L	B	BrEE*,,KKrEE	 2rx()))2;0F0FLLLrx)***\+&& 	"NN28G,---OOBHX.///"&BHYY	77>3J3JCPPPNN28I.///	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	+,,,+,,,               KOOKOOOOE77#?@@AAAOOE77#9::;;;OOK%i0111NN;$W-...N4DD 0 0)#.////0 0s9   A2HBF, H,F0	0H3F0	4AHHHc                       e Zd ZdZd ZdS )ThreadingTestz0Unit tests for thread local contexts in Decimal.c                 l   | j         j        }| j         t          k    r!| j         j        s|                     d           |j        }|j        }|j        }d|_        d|_        d|_        t          j	                    | _
        t          j	                    | _        t          j	                    | _        t          j        t          | f          }t          j        t          | f          }|                                 |                                 | j                                         | j                                         t$          | j                  D ]"}|                     |j        |                    #|                                 |                                 ||_        ||_        ||_        d S )Nzcompiled without threading   r   )targetr  )r   DefaultContextr   HAVE_THREADSr  r+   r]  rX  	threadingEventr!  r   r3  Threadr-  r5  startr"  r2   r%  rR  r  )r   r<  	save_prec	save_emax	save_eminth1th2r,  s           r   test_threadingzThreadingTest.test_threading  sr   4<1T\%>MM6777 #'	"'	"'	 '( (( (( ((gTG<<<gTG<<<				4<( 	8 	8C^1#67777





'''r!   N)r   r_  r`  ra  rG  r   r!   r   r7  r7  |  s)        ::
$( $( $( $( $(r!   r7  c                       e Zd ZeZdS )CThreadingTestNr  r   r!   r   rI  rI    r  r!   rI  c                       e Zd ZeZdS )PyThreadingTestNr  r   r!   r   rK  rK    r  r!   rK  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )UsabilityTestz*Unit tests for Usability cases of Decimal.c                    | j         j        } |d          } |d          } |d          }|                     ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     |d           |                     d|           |                     |d           |                     |d           |                     |d           |                     |t                                 |                     |t                     t          t          |t          d                              }|d d          }t          j        |           |                                 |                     ||           d S )Nz23.42rn     rm  r  gY@@r  )r   r   assertGreaterassertGreaterEqual
assertLessassertLessEqualr@  assertNotEqualobjectlistmaprx  r.  shuffler>  )r   r   dadbdcr  bs          r   test_comparison_operatorsz'UsabilityTest.test_comparison_operators  s   ,&WWWWWT]] 	2r"""B'''BR$$$R   B###R$$$B''' 	2r"""BR    	B'''B%%%B)))B''' WeCjj))**qqqTq	Ar!   c                    | j         j        } |d          } |d          }|                     |d           |                     |d           |                     |d           |                     |d           |                     |d           |                     |d           |                     d|           |                     d|           |                     d|           |                     d|           |                     d|           |                     d|           |                     d |d                     d S )N0.253.0      @      ?g      ?r  r  )r   r   rR  rS  rP  rQ  rT  r@  r   r   rY  rZ  s       r   test_decimal_float_comparisonz+UsabilityTest.test_decimal_float_comparison  sN   ,&WV__WU^^C   R%%%2t$$$D)))B$$$T"""3###R(((b!!!T2&&&D"%%%b!!!C00000r!   c                    | j         j        } |d          } |d          }|                     |d           |                     d|           |                     |d           |                     d|           |                     d|           |                     |d           |                     |d           |                     d|           |                     |                    d          t                     |                     |                    d          t                     |                     |                    d          t                     |                     |                    d          t                     d S )Nr_  r`  y      ?        y      ?        y      @        y      @      ?)	r   r   rT  r@  r  r  NotImplementedr  r  rc  s       r   test_decimal_complex_comparisonz-UsabilityTest.test_decimal_complex_comparison  s\   ,&WV__WU^^B)))Vb)))g''''B'''&2&&&f&&&B)))Vb)))bii''888bii''888bii''888bii''88888r!   c           
       	   | j         j        }t          | j                  j        }| j         j        }| j         j        }| j         j        }t          rt          j        nd}t          rt          j	        nd}t          rt          j
        nd} |||          }	 ||	          5  ||	_        |                      |d           |dd                     |                      |dd           |d                     |                      |dd           |d	t          |          z                        |                      |d
t          |          z              |dd                     |                      |dd           |d	t          |          z                        |                      |d
t          |          z              |dd                     |                      |d           |dd                     |                      |dd           |d                     d|	_        |                      |d          dz   |dd                     |                      |dd           |d          dz             |                      |dd           |dt          |          z                        |                      |dt          |          z              |dd                     |                      |d           |dd                     |                      |d           |dd                     |                      |d           |dd                     |                      |d           |dd                     |                     | |d          j         |dd                     |                     t,           |dd                               |d                               |                      |d           |dd                     |                      |dd           |d                     d d d            d S # 1 swxY w Y   d S )Nɚ;6eilʈr]  rX  r   r  l	   ZmH;5B ru  1ez-1el   !0QYr  r  i,  r  i6l   c(	 9er  l   g] {   lg] r  r  i)r   r   r   Fractionr.   r  r   r   r   MIN_EMIN	MIN_ETINYr+   rR  r;  r@  rT  rS  rQ  rP  rj  r  r  rf  r  )
r   Dr  r.   r  r   emaxeminetinyr  s
             r    test_decimal_fraction_comparisonz.UsabilityTest.test_decimal_fraction_comparison  s   L dl#,,&|0<8 -qzzI.qzzJ 1kGD)))\!__ 	5 	5AFOOAAaDD!!A&K"L"LMMMOOAAb!FGG1NNNOOAAaFFAAdSZZ&7$8$8999OOAAec%jj01111Qq66:::OOAAa 9::AAdSZZ>O<P<PQQQOOAAec%jj01111Q7P3Q3QRRRQQuXXqq2ww///QQqWWaahh///AF!Q!A///!A!Q///  9j!9!911TCII=M;N;NOOO##AAdSYY&6$7$79j9Q9QRRRqqxx;s););<<<qqxx<)<)<===OOAAfIIqqS'9'9:::OOAAfIIqqc':':;;;.%2cKKKMM.!!Bs))*:*:11U88*D*DEEE%!!Bs))444"S		11U884447	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   OQ33Q7:Q7c                 D   | j         j        } |d          }t          j        |          }|                     t	          |          t	          |                     t          j        |          }|                     t	          |          t	          |                     d S )Nz43.24)r   r   rn   r@  rC  deepcopy)r   r   r   r  r[  s        r   test_copy_and_deepcopy_methodsz,UsabilityTest.test_copy_and_deepcopy_methods)  s    ,&GGIaLLA1&&&]1BA'''''r!   c                 F     j         j         j         j        } fd} | d                      | d                      | d                      | d                      | d                     fddD             }|                     d	           d
           d           d           d           d           d           d           d           d           d           d           d           d           d           d          g           |D ];}                      ||          t          t          |                               <g d}|D ]H}t          |          } |          }                      ||          t          |                     I |            5 }	 d          }
d|	_         ||
          }d|	_         ||
          }d|	_         ||
          }                     ||                                ||           d|	_        dd z  }
                      | |
                     ||
                     d d d            d S # 1 swxY w Y   d S )!Nc                 z    t          |           }|                                 }                    ||           |S r   )hash__hash__r@  )r   r  r\  r   s      r   hashitz.UsabilityTest.test_hash_method.<locals>.hashit7  s6    QA

AQ"""Hr!   rO  r  r  nan123-NaNc           	      h    g | ].}t          d d          D ]}dD ]} |d|z  |z   z            /S )r  rt  r  )rx  )r   r4   ry  rz  r   s       r   r'  z2UsabilityTest.test_hash_method.<locals>.<listcomp>D  su     , , , %c2, , #*	, ,  	 wtQTAX// , , , , ,r!   )r                     rs  !   =   >   ?   @   A   B   r  r  r@  z-0.000rW  z-0E1210.0z	-23.000001230E100z
-4.5678E50l       z	1.634E100z
90.697E100z
188.83E100z
1652.9E100	56531E100)r  r  r?  z-.0e1z34.02.5z
112390.625z	-0.515625z123456789.1   r  r  '  iL  i  )	r   r   r  extendr@  r|  r  r  r+   )r   r  r~  r  r  test_stringsr   r   r   r  r  h1h2h3r   s   `             @r   test_hash_methodzUsabilityTest.test_hash_method2  s   ,&|0	 	 	 	 	 	wwr{{wwz""###ww{##$$$wwx  !!!wwv, , , ,!A, , ,
 	!!  $$
##%% )** $$%%%%%%$$) 	 	 	0 ! 	> 	>EVVE]]DU,<,<====B B B 	1 	1AaA

AVVAYYQ0000\^^ 	<q &&AAFBAFBAFBR$$$R$$$AFAVVGGAJJ//;;;#	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   B+JJJc                    | j         j        }|                     t          t           |d                      |d          }|                     t	          |          t                              |                      G d d          } G d d||          } |d          }|                     t	          |          t                              |                     d S )Nr  r}  c                       e Zd Zd ZdS )-UsabilityTest.test_hash_method_nan.<locals>.Hc                     dS )Nr  r   r   s    r   r}  z6UsabilityTest.test_hash_method_nan.<locals>.H.__hash__  s    rr!   N)r   r_  r`  r}  r   r!   r   Hr    s#            r!   r  c                       e Zd ZdS )-UsabilityTest.test_hash_method_nan.<locals>.DN)r   r_  r`  r   r!   r   rr  r    s        Dr!   rr  )r   r   rj  r2  r|  r@  rU  r}  )r   r   r  r  rr  s        r   test_hash_method_nanz"UsabilityTest.test_hash_method_nan  s    ,&)T776??;;;efooe&<&<===	 	 	 	 	 	 	 		 	 	 	 	 	 	 	%efooe&<&<=====r!   c                    | j         j        } |d          } |d          }d}d}|                     t          ||          |           |                     t          ||          |           |                     t	          ||          |           |                     t	          ||          |           |                     t          ||          |           |                     t          ||          |           |                     t	          ||          |           |                     t	          ||          |           d S )N15.32z28.5r  r  )r   r   r  minmax)r   r   r  r  l1l2s         r   test_min_and_max_methodsz&UsabilityTest.test_min_and_max_methods  s   ,&WWWV__ 	c"Rjj"%%%c"Rjj"%%%c"Rjj"%%%c"Rjj"%%% 	c"Rjj"%%%c"Rjj"%%%c"Rjj"%%%c"Rjj"%%%%%r!   c                     | j         j        }|                      |d                     |                      |d                     d S )Nr   z0.372)r   r   r%  r#   rg  s     r   test_as_nonzerozUsabilityTest.test_as_nonzero  sL    ,& 	$$$(()))))r!   c                     | j         j        } |d          }|                     t          |          d           |                     t	          |          d           d S )Nr  zDecimal('15.32'))r   r   r@  r;  r?  r  s      r   test_tostring_methodsz#UsabilityTest.test_tostring_methods  sZ    ,&GGQ)))a"455555r!   c           
         | j         j        } |d          } |d          }|                     t          |          d           |                     t          |          d           |                     t	          |          d           |                     t	          |          d           g d}|D ]6\  }}|                     t          j         ||                    |           7|                     t          t
          j         |d                     |                     t          t
          j         |d                     |                     t          t
          j         |d	                     |                     t          t
          j         |d
                     |                     t          t
          j         |d                     g d}|D ]6\  }}|                     t          j
         ||                    |           7|                     t          t
          j
         |d                     |                     t          t
          j
         |d                     |                     t          t
          j
         |d	                     |                     t          t
          j
         |d
                     |                     t          t
          j
         |d                     g d}|D ]1\  }}|                     t           ||                    |           2|                     t          t           |d                     |                     t          t           |d                     |                     t          t           |d	                     |                     t          t           |d
                     |                     t          t           |d                     g d}|D ]@\  }}}	|                     t          t           ||          |                    |	           Ad S )N66r  r  r  gp=
ף.@)	z123.00rn  3.2r  )3.54r  )3.899r  )-2.3r  z-11.0ir?  r   z-0E3r   )89891211712379812736.1l   {#'s{M r  r  r  r\  r  )	r  )r  r  r  r  r  r  r  r  r  r  r  )r  l   {#'s{M )r  r  r  r  r  r  r  r  )z-3.5)r  r  )r  r  )-0.5r   )0.5r   )r;  r  )r  r  )z3.5r  ))123.456r  z0E+4)r  r  z0E+3)r  r  z1E+2)r  ru  z1.2E+2)r  r   r`  )r  r  z123.5)r  r  123.46)r  r  r  )r  r  z123.4560)z123.455r  r  )z123.445r  z123.44)r\  r  r}  )r  ir}  )sNaN314r  NaN314)r   r   r@  r  r  mathr   rj  r  OverflowErrorceilroundr;  )
r   r   r  r  
test_pairsr   rK  test_triplesry  r  s
             r   test_tonum_methodsz UsabilityTest.test_tonum_methods  s   ,&WT]]WW 	R"%%%R"%%% 	rB'''rE***
 
 

  	8 	8DAqTZ

33Q7777*dj''&//BBB*dj''&//BBB*dj''(2C2CDDD-WWU^^DDD-WWV__EEE
 
 

  	7 	7DAqTYwwqzz22A6666*diAAA*diAAA*di1B1BCCC-GGENNCCC-GGFOODDD  
$  	3 	3DAqU771::..2222*eWWV__===*eWWV__===*eWWX->->???-???-@@@    $ 	; 	;GAq!Swwqzz1!5!566::::	; 	;r!   c                 *   | j         j        }dD ]}t           ||                    }|                     t	          j        |                     t	          j        d|          }|                     ||                    d          rdnd           d S )N)r  nan1234-nanz-nan2468r  r  g      )	r   r   r  r#   r  r   rt   r@  r  )r   r   r   r   rz  s        r   test_nan_to_floatzUsabilityTest.test_nan_to_float  s     ,&7 	G 	GAggajj!!AOODJqMM***=a((DT1<<+<+<#E44#FFFF		G 	Gr!   c                     | j         j        }dD ].} ||          }|                     t          t          |           /d S )N)snanz-snansnan1357z	-snan1234)r   r   rj  r  r  )r   r   r   r   s       r   test_snan_to_floatz UsabilityTest.test_snan_to_float"  sM    ,&; 	4 	4A

Aj%3333	4 	4r!   c                    | j         j        } |d          }|                     |t          t	          |                                |d          }|                     |t          t	          |                                |d          }|                     |t          t	          |                                |d          }|                     |t          t	          |                               d S )Nr  r  r  r  )r   r   r@  r<  r?  r  s      r   test_eval_round_tripz"UsabilityTest.test_eval_round_trip(  s    ,& G\##DaMM*** G^%%DaMM*** G*,,DaMM*** G:<<DaMM*****r!   c                 L   | j         j        } |d          }|                     |                                d            |d          }|                     |                                d            |d          }|                     |                                d            |d          }|                     |                                d            |d	          }|                     |                                d
            |d          }|                     |                                d            |d          }|                     |                                d            |d          }|                     |                                d            |d          }|                     |                                d            |d          }|                     |                                d            |d          }|                     |                                d            |d          }|                     |                                d            |d          }|                     |                                d           d S )Nr   r  rq  r  r  r  r  )r   r  r  )r   r   r   r  r   rw  r  r  r  )r   r  r   rw  r  r  r  )r  r   r   r   %   )r  r  r  )r  r   r  )r   r  ry  )r   r  ry  )r  r  Nr  r   r  )r  r   ry  )r   r  r  )r  )r   r  r  r  r  )r  r  r  )r   r   r@  as_tupler  s      r   test_as_tuplezUsabilityTest.test_as_tuple;  so   ,& GAJJ|555 GCLL~777 G%&&'LNNN GJ~777 G355'?AAAG'))}555G[""}555 G466'@BBBG(**|555G\##|555 G^%%~666G+--~666G+--~66666r!   c           	         | j         j        }|                     t          |j         |d                     |                     t          |j         |d                     |                     t
          |j         |d                     |                     t
          |j         |d                     t          dd          D ]}t          d          D ]}dD ]} |d	|||fz            }|                                }|\  }}|                     |t                     |                     |t                     |                     |t                     | 
                    |d
           |                     t          j        ||          d           |                      ||           ||          z  |           d S )Nr  r  r  snan123r  r    )r  r  z%s%dE%dr   r  )r   r   rj  r  as_integer_ratior  rx  r  tupler  rP  r@  r  gcd)	r   r   rZ  coeffrz  r   pqr  r  s	            r   test_as_integer_ratioz#UsabilityTest.test_as_integer_ratioh  s    ,& 	-!2GGENN	D 	D 	D-!2GGFOO	E 	E 	E*!2GGFOO	E 	E 	E*!2GGI4F4F	H 	H 	H Q<< 	A 	ACt A A$ A AD	T5#,> >??A++--BDAq ))"e444))!S111))!S111 &&q!,,,$$TXa^^Q777 $$WWQZZ''!**%<a@@@@!AA	A 	Ar!   c                 
   | j         j        } G d d|          } |d          } |d          }||z   }|                     t          |          |           |                    |          }|                     t          |          |           t          j        |          }|                     t          |          |           |                     ||           t          j        |          }|                     t          |          |           |                     ||            |d          } ||          }|                     t          |          |           |                     ||            ||          }|                     t          |          |           |                     ||           |                     |j        d             ||          }|                     t          |          |           |                     ||           d|_         ||          }|                     t          |          |           |                     ||           |                     |j        d            d S )Nc                       e Zd ZdZdS )1UsabilityTest.test_subclassing.<locals>.MyDecimalN)r   r_  r`  r  r   r!   r   	MyDecimalr    s        AAAr!   r  r  r  1.0r*   )	r   r   r  r:  r  rn   r@  rx  r  )r   r   r  r  r  r   r  r4   s           r   test_subclassingzUsabilityTest.test_subclassing  s\   ,&	 	 	 	 	 	 	 	 Yq\\Yq\\Gd1ggw'''FF2JJd1ggw'''IbMMd1ggy)))BM"d1ggy)))B GENNGAJJd1ggw'''A IaLLd1ggy)))Aac4    GAJJd1ggw'''A IaLLd1ggy)))Aac4     r!   c           
         | j         j        }| j         j        } |            }|                     t	           |d                                                    t	          |                     |d                                         d S Nr   )r   r   r  r@  r;  r   r   r   r  r  s       r   test_implicit_contextz#UsabilityTest.test_implicit_context  s    ,&\,
 JLLWWQZZ__..//QVVGGAJJ//00	2 	2 	2 	2 	2r!   c                 T,   | j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j	        }	| j         j
        }
| j         j        } | |                      5 }d|_        d|_        d|_         |d          } |d          } |d          }|                                 |                     t#          |                    d                     d           |                     |j        |	                    |                     |j        |
                    |                                 |                     ||j        d            |                     |j        |                    |                     |                    d           d	           |                     |                    d           d
           |                                 |                     t#          |                    d                     d           |                     |j        |	                    |                     |j        |
                    |                                 |                     | |d          j        d            |                     |j        |                    |                                 |                     t#          |                    d                     d           |                     |j        |	                    |                     |j        |
                    |                                 |                     | |d          j        d            |                     |j        |                    |                                 |                     t#          |                    d                     d           |                     | |d          j        d            |                     |j        |                    |                                 |                     t#          |                    d                     d           |                     ||j        d            |                     |j        |                    |                                 |                     t#          |                    d                     d           |                     | |d          j        d            |                     |j        |                    |                                 |                     t#          |                    d                     d           |                     | |d          j        d            |                     |j        |                    |                                 |                     t#          |                    d                     d           |                     ||j        d            |                     |j        |                    |                     t#          |                     d                     d           |                                 |                     t#          |!                    d                     d           |                     |j        |                    |                     |j        |	                    |                     |j        |
                    |                     |j        |                    |                     |j        |                    |                                 |                     ||j!        d            |                     |j        |                    d|_"        |                     t#          |#                    d                     d           d|_"        |                                 t#          |$                     |d          d                     }|                     |d           |                     ||j$         |d          d            |                     |j        |                    |                                 t#          |%                    dd                     }|                     |d           |                     ||j%         |d          d            |                     |j        |                    |                                 t#          |&                    dd                     }|                     |d           |                     ||j&        dd            |                     |j        |                    |                                 t#          |'                    dd                     }|                     |d           |                     ||j'        dd            |                     |j        |                    |                                 t#          |(                    dd                     }|                     |d            |                     ||j(        dd            |                     |j        |                    |                                 t#          |)                    dd                     }|                     |d           |                     ||j)         |d          d            |                     |j        |                    |                                 t#          |*                    dd                     }|                     |d           |                     ||j*         |d          d            |                     |j        |                    |                                 t#          |+                    dd                     }|                     |d           |                     ||j+         |d          d            |                     |j        |                    |                                 t#          |,                    dd                     }|                     |d           |                     ||j,         |d          d            |                     |j        |                    |                                 t#          |-                    dd                     }|                     |d            |                     ||j-        dd            |                     |j        |                    |                                 t#          |.                    d!d                     }|                     |d"           |                     ||j.        dd            |                     |j        |                    |                                 t#          |/                    dd                     }|                     |d#           |                     ||j/        d$d            |                     |j        |                    |                                 t#          |0                    d!d                     }|                     |d"           |                     ||j0        d$d            |                     |j        |                    |                                 t#          |1                    d!d%d                     }|                     |d&           |                     ||j1         |d          d%d            |                     |j        |                    td          |_3        t#           |d'          4                    d d (                    }|                     |d           tj          |_3        t#           |d'          4                    d d (                    }|                     |d)           t#           |d'          4                    tl          d (                    }|                     |d           |                                 |                     | |d          j4        d            |                     |j        |                    td          |_3        t#           |d'          7                    d d (                    }|                     |d           tj          |_3        t#           |d'          7                    d d (                    }|                     |d)           t#           |d'          7                    tl          d (                    }|                     |d           |                                 |                     | |d          j7        d            |                     |j        |                    td          |_3        t#           |d'          8                    d d (                    }|                     |d           tj          |_3        t#           |d'          8                    d d (                    }|                     |d)           t#           |d'          8                    tl          d (                    }|                     |d           |                                 |                     | |d          j8        d            |                     |j        |                    tl          |_3        t#           |d*          9                     |d+          d d ,                    }|                     |d-           tj          |_3        t#           |d*          9                     |d+          d d ,                    }|                     |d.           t#           |d*          9                     |d+          tl          d ,                    }|                     |d-           |                                 |                     ||j9         |d/          tl          d (           |                     |j        |                    d d d            n# 1 swxY w Y    | |                      5 }d|_        d|_        d|_         |d 0          5 }|                     |j        d           |                     |j        d           |                     |j        d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )1Nr  r1  i1111e9999z1e-9999r&   z1.609487E+48FTz4.709530ru  z2.045323r  r   1111000z9.999999E+999r  r  re  
+Subnormalz0E-1005r  Nan891287828
NaN1287828i    r  r}  e   101rn  r-  r  11100z1.11E+9r  r  225r;  r,   r&   r  z1.50001z1e-3)rZ  r,   r&   z1.501z1.500z1e-10)r  ):r   r   r.   r  r   r   r   r   r   r   r   r   r+   r]  rX  r/  r@  r;  rZ  r#   rR  rj  r  r   r   lnlog10logbry   r   r   r   rg   r   capitalsr   r$  ri   rc   r   r   r  r   r  r   r   rotatescalebshiftfmar/   r,   to_integralr   r   r   r   quantize)r   r   r.   r  r   r   r   r   r   r   r   r   r  r  r  zrE  r&   s                     r   test_none_argszUsabilityTest.test_none_args  s   ,&,&|0<84<(L*	L*	,&,&,&\''))$$ W	7AFAFAFA!!A	""A MMOOOSt!4!455~FFFOOAGG,---OOAGG,---MMOOOht<<<OOAGH-...MM!++d+33U;;;MM!...66===MMOOOSd!3!344jAAAOOAGG,---OOAGG,---MMOOO.MMMOOAG$45666MMOOOS!6!677DDDOOAGG,---OOAGG,---MMOOO.0A4PPPOOAG$45666MMOOOS!5!566<<<nggajjotLLLOOAGN3444MMOOOS!1!1$!1!?!?@@)LLL.0@$OOOOOAG$45666MMOOOSd!;!;<<oNNN.0JTXYYYOOAG$45666MMOOOST!:!:;;ZHHH.0ISWXXXOOAG$45666MMOOOST!:!:;;SAAAhTBBBOOAGH-...S!=!=>>MMMMMOOOS!5!566	BBBOOAGG,---OOAGG,---OOAGG,---OOAGI.///OOAGI.///MMOOOh===OOAGH-...AJS!>!>??KKKAJ MMOOOaii 7 7iFFGGCS,///.	776??TXYYYOOAG$45666MMOOOa&&tT&::;;CS$'''.0@''%..Z^___OOAG$45666MMOOOammCm6677CS%(((.sDQQQOOAG$45666MMOOOall3l5566CS%(((.c4PPPOOAG$45666MMOOOammCm6677CS$'''.sDQQQOOAG$45666MMOOOaeeCe..//CS%(((.wwvPTUUUOOAG$45666MMOOOaiiTi2233CS%(((.	776??TXYYYOOAG$45666MMOOOaeeCe..//CS%(((.wwvPTUUUOOAG$45666MMOOOaiiTi2233CS%(((.	776??TXYYYOOAG$45666MMOOOa&&sD&99::CS$'''.0@#tTTTOOAG$45666MMOOOahhq$h//00CS'***.#tLLLOOAG$45666MMOOOahhq$h//00CS),,,.%NNNOOAG$45666MMOOOaggag..//CS'***.MMMOOAG$45666 MMOOOaeeAq$e//00CS%(((hwwx/@/@!TRRROOAGH-... )AJggenn00$0MMNNCS#&&&#AJggenn00$0MMNNCS#&&&ggenn00(D0QQRRCS#&&&MMOOO.0KUYZZZOOAG$45666(AJggenn66d6SSTTCS#&&&#AJggenn66d6SSTTCS#&&&ggenn66RV6WWXXCS#&&&MMOOO.0Q[_```OOAG$45666(AJggenn66d6SSTTCS#&&&#AJggenn66d6SSTTCS#&&&ggenn66RV6WWXXCS#&&&MMOOO.0Q[_```OOAG$45666!AJggi((11ggfooPT^b1ccddCS'***#AJggi((11ggfooPT^b1ccddCS'***ggi((11ggfooPXbf1gghhCS'***MMOOO.
GGG<L<LW_imnnnOOAG$45666oW	7 W	7 W	7 W	7 W	7 W	7 W	7 W	7 W	7 W	7 W	7 W	7 W	7 W	7 W	7r \''))$$ 	/GLGLGL$''' /1  +++  ---  .../ / / / / / / / / / / / / / /		/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/sb   ASAU'U'AU+U.AU+V"AXV'AAXW9AXXAX		X	AXXAX		XAXXAX!X$AX!c           	         | j         j        }|                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d          	                    d           |d          	                     |d                               |                      |d          
                    d           |d          
                     |d                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d	                              d           |d	                               |d                               |                      |d                              d
           |d                               |d
                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d                              d           |d                               |d                               |                      |d                               |d          d           |d                               |d           |d                               |                      |d                              dd           |d                               |d           |d                               |                      |d                              d |d                     |d                               |d           |d                               d S )Nr  r  iu'    i7  rn  r  r  i   r  r  z9.123r  ru  irm  C   )r   r   r@  r$  ri   rk   rm   rc   r   r   r  r   r  r   r   r  r   r  r   r  r  r  rg  s     r   test_conversions_from_intz'UsabilityTest.test_conversions_from_int	  s    ,&++A.. ++GGAJJ77	9 	9 	922155 22771::>>	@ 	@ 	@11!44 11''!**==	? 	? 	?55a88 55ggajjAA	C 	C 	C33D99 33GGDMMBB	D 	D 	D22488 22774==AA	C 	C 	C33D99 33GGDMMBB	D 	D 	D))#.. ))''#,,77	9 	9 	9--c22 --ggcll;;	= 	= 	=))#.. ))''#,,77	9 	9 	9--c22 --ggcll;;	= 	= 	=11#66 11''#,,??	A 	A 	A//44 //==	? 	? 	?44T:: 44WWT]]CC	E 	E 	E,,Q// ,,WWQZZ88	: 	: 	:33D99 33GGDMMBB	D 	D 	D))0066 ))00??	A 	A 	A++B// ++GGBKK88	: 	: 	: 	))''"++r:: ))''"++wwr{{CC	E 	E 	E))"b11 ))''"++wwr{{CC	E 	E 	E))"ggbkk:: ))''"++wwr{{CC	E 	E 	E 	E 	Er!   N)r   r_  r`  ra  r]  rd  rg  rv  ry  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r   r!   r   rM  rM    sb       44" " "H1 1 1&9 9 9((5 (5 (5T( ( (L< L< L<\> > >& & &(* * *6 6 6e; e; e;NG G G4 4 4+ + +&+7 +7 +7ZA A AB-! -! -!^2 2 2m/ m/ m/^/E /E /E /E /Er!   rM  c                       e Zd ZeZdS )CUsabilityTestNr  r   r!   r   r  r  	  r  r!   r  c                   ,     e Zd ZeZ fdZ fdZ xZS )PyUsabilityTestc                     t                                                       t          j                    | _        t          j        d           d S NiX  superr   sysget_int_max_str_digits_previous_int_limitset_int_max_str_digitsr   r   s    r   r   zPyUsabilityTest.setUp	  <    #&#=#?#? "4(((((r!   c                 z    t          j        | j                   t                                                       d S r   r  r  r  r  tearDownr  s    r   r   zPyUsabilityTest.tearDown	  3    "4#;<<<r!   r   r_  r`  r  r   r   r   __classcell__r   s   @r   r  r  	  V        G) ) ) ) )
        r!   r  c                   `    e Zd Zd Zd Zd Zed             Zd Zd Z	d Z
d Zd	 Zd
 Zd ZdS )PythonAPItestsc                 v   | j         j        }|                     t          |t          j                             |                     t          |t          j                             |                      |d          t          j                   | 	                     |d          t          j                   d S r  )
r   r   r#   
issubclassnumbersNumberr%  Realr  assertNotIsInstancerg  s     r   test_abczPythonAPItests.test_abc	  s    ,&
7GN;;<<<GW\::;;;ggajj'.999  W\:::::r!   c                    t          t          j        dz             D ]>}| j        j        }t
          j        d         }| j        t
          j        d<    |d          }t          j        ||          }t          j        |          }| 	                    ||           t          rt                              d          }t                              d          }t          t
          j        d<   t          j        ||          }	t          t
          j        d<   t          j        |	          }
|                     |
t          j                   | 	                    |
|           t          t
          j        d<   t          j        ||          }t          t
          j        d<   t          j        |          }
|                     |
t          j                   | 	                    |
|           t                              d                                          }t                              d                                          }t          t
          j        d<   t          j        ||          }	t          t
          j        d<   t          j        |	          }
|                     |
t          j                   | 	                    |
|           t          t
          j        d<   t          j        ||          }t          t
          j        d<   t          j        |          }
|                     |
t          j                   | 	                    |
|           |t
          j        d<   @d S )Nr  r   z-3.141590000z-3.123e81723)rx  pickleHIGHEST_PROTOCOLr   r   r  modulesdumpsloadsr@  r   r  r  r  DecimalTuple)r   protor   savedecimalr   r  r)  r  r  sxr  sys               r   test_picklezPythonAPItests.test_pickle	  s   62Q677 0	1 0	1El*G+i0K &*\CK	"''AQ&&AQAQ""" "'IIn--IIn--)*I&\!U++)*I&L$$%%a333  A&&&)*I&\!U++)*I&L$$%%a333  A&&&IIn--6688IIn--6688)*I&\!U++)*I&L$$%%a888  A&&&)*I&\!U++)*I&L$$%%a888  A&&&%0CK	""a0	1 0	1r!   c           	         | j         j        }t          dd          D ]}d|dz  z  }|                     t	           ||                    t	          t          |                                ||          }|                    t                    }|                      |t	          |                    |           |                     t          t           |d                     |                     t          t           |d                     |                     t          t           |d                     |                     t          t           |d                     d S )	N   %0.2f      Y@r  r  r  r  )r   r   rx  r@  r  r  r  r   rj  r  r  r   r   r  r   r   r  s         r   test_intzPythonAPItests.test_int-
  s.   ,&tS!! 	1 	1A1u9%AS__c%((mm<<<

Aj))AWWSVV__a0000*c776??;;;*c776??;;;-ggenn===-ggfoo>>>>>r!   c                     | j         j        }t          dd          D ].}|                     t	           ||                    |           /d S )Nrv  i  )r   r   rx  r  r  r   r   r  s      r   test_small_intszPythonAPItests.test_small_ints>
  sR    ,&r3 	. 	.AMM#ggajj//1----	. 	.r!   c           	         | j         j        }t          dd          D ]}d|dz  z  }|                     t	           ||                    t	          t          |                                ||          }|                    t                    }|                      |t          j	        |                    |           d S )Nr<  r=  r>  r?  )
r   r   rx  r@  r  r  r  r   r  truncr@  s         r   
test_trunczPythonAPItests.test_truncE
  s    ,&tS!! 	8 	8A1u9%AS__c%((mm<<<

Aj))AWWTZ]]33Q7777	8 	8r!   c           	         | j         j        } G d d|          }|                     t          ||                     |                    d          }|                     t          |          |           |                     t          |          d           |                     |j        d           d}|                     |                    |           ||                     |                     |                    t          d                    
                                           |                     |                    t          d                                                               |                     |                    t          d	                                                               |                     t          |                    t          d                              t           |d
                               |                     t          |                    t          d                              t           |d                               |                     t          |                    t          d	                              t           |d                               |                     t          |j        d           t          d          D ]f}t          j        d          t          j                    dz  dz
  z  }|                     |t          |                    |                               gd S )Nc                       e Zd Zd ZdS )1PythonAPItests.test_from_float.<locals>.MyDecimalc                     d| _         d S )Nr  )r  )r   _s     r   r  z:PythonAPItests.test_from_float.<locals>.MyDecimal.__init__V
  s    r!   Nr  r   r!   r   r  rJ  U
  s#            r!   r  r  r  r  l   s\&5$3|	 r  r  r  r}  r  r  abcr  r  r  r  )r   r   r#   r)  r  r@  r:  r;  r  r  r   r   rj  r2  rx  r.  r  )r   r   r  r  bigintrK  r  s          r   test_from_floatzPythonAPItests.test_from_floatQ
  s   ,&	 	 	 	 	 	 	 	 	
9g66777  %%a),,,QK	M 	M 	Mc""".--f55yy7H7HIII	,,U5\\::BBDDEEE	,,U5\\::FFHHIII	,,U6]];;GGIIJJJY11%,,??@@WWU^^,,	. 	. 	.Y11%,,??@@WWZ0011	3 	3 	3Y11%--@@AAWW[1122	4 	4 	4)Y%95AAAs 	@ 	@A"4((FMOOc,AC,GHAQi&:&:1&=&= > >????	@ 	@r!   c                 2   | j         j        }| j         j        }| j         j        } |dt                    }|                     |                    t          j                   |d                      |dt                    }|                     |                    t          j                   |d                      |d|g          }| 
                    ||j        t          j                   |                     t          |                    d                    d           |                     t          |                    d                    d	           |                     t          |                    d
                    d           d S )Nrw  )r+   r,   z3.1415rM  )r+   r-          zDecimal('-0')r  zDecimal('1')r  zDecimal('10'))r   r   r.   r   r   r@  create_decimal_from_floatr  pir   rj  r?  )r   r   r.   r   r&   s        r   test_create_decimal_from_floatz-PythonAPItests.test_create_decimal_from_floatq
  s   ,&,&,&'q:666--dg66GH	
 	
 	
 'q8444--dg66GH	
 	
 	
 'q	222-G	
 	
 	

 	g??EEFF(	* 	* 	*g??DDEE'	) 	) 	)g??CCDD(	* 	* 	* 	* 	*r!   c                    | j         j        }| j         j        }| j         j        } |dd          }|                      |d                               |d                     |d                     |                      |d                               |d          t                     |d                     |                     | |d	          j         |d
          |            |            } |d          }|                    | |d          t                    }|                     | |d                     d S )Ni iayrk  z7.335r|  z7.34r,   z7.3310e999991e100000r  z0.871831e8001e797)r&   rZ  r,   z	8.71E+799)r   r   r.   r   r@  r  r   rj  )r   r   r.   r   r  r   r  s          r   test_quantizezPythonAPItests.test_quantize
  sk   ,&,&<8GV,,,GG%%ggenn55GFOO	
 	
 	
 	GG%%ggennz%JJGFOO	
 	
 	
 	GJ(''**=*=q 	 	
 	
 	

 GIIGN##JJqggg&6&6JLLGGK0011111r!   c                    | j         j        } |d          }|                     |j        |           |                     |j        d           |                     |                                |            |d          }|                     t          |          t          t          d                               |                     t          t          |dd           |                     t          t          |dd           |                     t          t          |dd           |                     t          t          |d	d           d S )
Nz9.8182731e181273r   r  r  realr  imag	conjugate__complex__)r   r   r@  r\  r]  r^  complexr  rj  r3  r/  rC  s      r   test_complexzPythonAPItests.test_complex
  s   ,&G&''######***GCLLWU1XX%6%6777.'1fcBBB.'1fcBBB.'1k3GGG.'1mSIIIIIr!   c                 $   | j         j        }| j         j        }| j         j        }| j         j        }| j         j        } |            }d|_        d|_        d|_         |            5 }|	                                 | 
                     |d|          d           | 
                     |d|          d           | 
                     ||d          d           | 
                     ||          d           |	                                 |                     ||d|           |                     |j        |                    |                     |j        |                    |	                                 | 
                     |d                              |          d	           |                     | |d
          j        |           |                     |j        |                    |                     |j        |                    |	                                 | 
                     |d                              |           |d                     |                     | |d          j        |           |                     |j        |                    |                     |j        |                    | 
                     |d                              |           |d                     | 
                     |d                              |          d           | 
                     |d                              |           |d                     | 
                     |d                              |           |d                     | 
                     |d                              |          d           | 
                     |d                              |          d           | 
                     |d                              |          d           | 
                     |d                              |           |d                     | 
                     |d                              |d          d           |	                                 |                     | |d          j         |d          |           |                     |j        |                    |                     |j        |                    | 
                     |d                               |d          |           |d                     | 
                     |d                               |d          |           |d                     | 
                     |d                               |d           |           |d                      | 
                     |d!                               |d"          |           |d#                     | 
                     |d!                               |d"          |           |d                     | 
                     |d                               |d$          |           |d%                     |	                                 |                     | |d          j          |d&          |           |                     |j        |                    |                     |j        |                    | 
                     |d'          !                     |d(          |           |d)                     | 
                     |d*          "                     |d+          |d	,           |d-                     |                     tF           |d          j$        |           |                     tF           |d          j%        |           |                     tF           |d          j&        |           |                     tF           |d          j'        |           |                     tF           |d          j(        |           |                     tF           |d          j)        |           |                     tF           |d          j*        |           |                     tF           |d          j+        |           |                      |d          ,                    |                     |                      |d          -                    |                     |                     tF           |d          j.        |           |                     tF           |d          j/        |           |                     tF           |d          j0        |           | 
                     |d.          1                    |          d           | 
                     |d          2                    |          d           | 
                     |d          3                    |          d/           | 
                     |d0          4                    |          d0           | 
                     |d1          5                     |d2          |          d           | 
                     |d1          6                     |d2          |          d           | 
                     |d3          7                     |d2          |          d           | 
                     |d4          8                    d|          d           | 
                     |d4          8                    d|          d           |	                                 |                     | |d4          j9        d|           |                     |j        |                    |                     |j        |                    | 
                     |d4          :                    d|          d           |                     tF          |j;        d5|           |                     tF           |d          j<        |           | 
                     |d          =                                d           |                     tF           |d$          j>        |           |                     tF           |d$          j?        |           |                     tF           |d          j=        d6           |                     tF           |d          j=        d67           d d d            d S # 1 swxY w Y   d S )8Nr  ru  r*   r  )r&   r  r   r  r  r  r  z0.7r  r  z-0.9z9.73z1E+19999'  z-2000i0r`  rn  z0.06250.2r  )r&   r  re  r  0.01z0.0101r?  z-0.3z0.02z-0.03r  r  r  1e109.99r;  r  9.9z0.9)thirdr&   r  z7E+1ir  z0.2111r-  0123g?r  )r  )@r   r   r.   r  r   r   r+   r]  rX  r/  r@  rj  r#   rR  r%  rZ  r  r   r   r   r   r  r   r   r   r$  ri   r  r   r  r   r   r  r   r  r2  r{   r}   r   r   r   r   r   r   r   r   adjustedr^  radixr  ry   rg   r   rc   r   r   r  r  r  r  r  	canonicalrq   rs   )r   rr  r.   r  r   r   xcr  s           r   test_named_parametersz$PythonAPItests.test_named_parameters
  sU   L ,&|0<8<(WYY\^^ b	BqMMOOOQQq"XXq)))QQq"---q111QQr333Q777QQr]]]A...NN.5"EEEOOBH%56777QW%56777NNQQqTTXXbX111555h!"===OOBHX.///QWX.///NNQQqTTWWRW00!!E((;;;.""EEEOOBH%56777QW%56777QQqTTZZZ33QQvYY???QQrUU--b-992>>>QQrUU__R_88!!F))DDDQQvYY000<<aaiiHHHQQvYY2222>>EEEQQwZZ99"9EEuMMMQQuXX777CCSIIIQQx[[--b-9911U88DDDQQx[[0010EErJJJNN.aff3QQuXXr  K K KOOBH%56777QW%56777QQvYY]]11X;;]CCQQuXXNNNQQvYY]]11X;;]CCQQuXXNNNQQuXX--aaii-DDQvYY( ( (QQvYY]]11W::r]BBAAfIINNNQQvYY..qqzz2.FFQuXX' ' 'QQuXX11!!D''21FF%QQQNN.ahh/6B  H H HOOBH%56777QW%56777QQvYY55aahh5KKQvYY( ( ( QQuXX\\%"A\NNQvYY( ( ( i1):BGGGi1DDDi1)92FFFi1bAAAi1rBBBi1rBBBi1DDDi1rBBBQQvYY000<<===OOAAfII2222>>???i1CCCi1DDDi1R@@@QQtWW\\"\55q999QQqTT000<<a@@@QQvYY33B3??NNNQQvYY44R4@@&IIIQQtWW004"0EEqIIIQQtWW//$/DDaHHHQQtWW004"0EEqIIIQQtWW^^Ar^::A>>>QQtWW^^Ar^::A>>>NNhaggna  = = =OOBHX.///QWX.///QQtWW]]2r]::A>>>isBGGGi1CCCQQqTT^^--q111i4)92FFFi4)<bIIIi1EEEi1SAAAEb	B b	B b	B b	B b	B b	B b	B b	B b	B b	B b	B b	B b	B b	B b	B b	B b	B b	Bs   &vxx	x	c                    | j         }|j        }|j        }|j        }|j        }|j        }|j        }|j        }|j        }	|j	        }
|j
        }|                     t          |t                               |                     t          ||                     |                     t          ||                     |                     t          |t                               |                     t          ||                     |                     t          |t                               |                     t          ||
                     |                     t          ||	                     |                     t          ||                     |                     t          ||	                     |                     t          ||
                     |                     t          ||                     |                     t          ||                     |                     t          ||                     |                     t          |	|                     |                     t          |
|                     |                     t          ||                     |                     t          |j        |                     |                     t          |j        |                     |                     t          |j        |                     |                     t          |j        t                               |                     t          |j        |                     d S r   )r   r   r   FloatOperationr   r   r   r   r   r   r   r#   r)  ArithmeticErrorr2  ZeroDivisionErrorConversionSyntaxDivisionImpossibleDivisionUndefinedInvalidContext)r   r   r   r   rt  r   r   r   r   r   r   r   s               r   test_exception_hierarchyz'PythonAPItests.test_exception_hierarchy%  s   ,"3"3 / /#%	%	///
#3_EEFFF
#35EFFGGG
>3CDDEEE
>9==>>>
>3CDDEEE
>3DEEFFF
8W55666
8W55666
8-=>>???
9g66777
9g66777
9i88999
9.>??@@@
9.>??@@@
7,<==>>>
7,<==>>>
7,<==>>>
7#;=MNNOOO
7#=?OPPQQQ
7#<>NOOPPP
7#<>OPPQQQ
7#9;KLLMMMMMr!   N)r   r_  r`  r.  r:  rA  r
   rD  rG  rO  rT  rZ  ra  rr  r{  r   r!   r   r'  r'  	  s        ; ; ;11 11 11f? ? ?" . . \.
8 
8 
8@ @ @@* * *82 2 20J J J nB nB nB`&N &N &N &N &Nr!   r'  c                       e Zd ZeZdS )CPythonAPItestsNr  r   r!   r   r}  r}  M  r  r!   r}  c                       e Zd ZeZdS )PyPythonAPItestsNr  r   r!   r   r  r  P  r  r!   r  c                      e Zd Zd Zee ej        e          d                                     Z	d Z
d Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d  Z&d! Z'd" Z(d# Z)d$ Z*d% Z+d& Z,d' Z-d( Z.d) Z/d* Z0d+ Z1d, Z2d- Z3d. Z4d/ Z5d0 Z6d1 Z7d2 Z8d3 Z9d4 Z:d5 Z;d6 Z<d7 Z=d8 Z>d9 Z?d: Z@d; ZAd< ZBd= ZCd> ZDd? ZEd@ ZFdAS )BContextAPItestsc           
      J   | j         j        }| j         j        }| j         j        }| j         j        } |            } |d d d d d d d d           }||fD ]}|                     |j        d           |                     |j        t                     |                     |j	        d           |                     |j
        d           |                     |j        d           |                     |j        d           t          | |dg            t          | |d|||g           d S )	N)r+   r,   r]  rX  r  ra   rR  r-   r  ?B r  r   rR  r-   )r   r.   r   r   r   r@  r+   r,   r/   r]  rX  r  ra   r(   )r   r.   r   r   r   r+  r)  r  s           r   r
  zContextAPItests.test_none_argsU  sK   ,&<84<(WYYW$Dt"$d$H H Hb 		9 		9AQVR(((QZ999QVV,,,QVW---QZ+++QWa(((4GR0004G.>.6.8 9 9 9 9		9 		9r!   r  c                    dd l }| j                                        }t          D ]7}|                    |          |_        |                     |j        |           8|                    d          }|                     t          t          |d|           |                    d          }|                     t          t          |d|           d S )Nr   r   r,   z	ROUND_ UP)
r  r   r.   RoundingModesr  r,   r@  rj  r2  r/  )r   r  r  rndr   s        r   r  z(ContextAPItests.test_from_legacy_stringsi  s     	L  ""  	. 	.C"88==AJQZ----++B//)WaQ???++N;;)WaQ?????r!   c                    t          t          j        dz             D ]}| j        j        }t
          j        d         }| j        t
          j        d<    |            }t          j        t          j        ||                    }| 	                    |j
        |j
                   | 	                    |j        |j                   | 	                    |j        |j                   | 	                    |j        |j                   | 	                    |j        |j                   | 	                    |j        |j                   | 	                    |j        |j                   | 	                    |j        |j                   t$          rt$          t&          ft&          t$          fgnt&          t&          fg}|D ]t\  }}t)          t*                    D ]X\  }	}
t)          t,          |                   D ]6\  }}
t)          t,          |                   D ]\  }}
t/          j        dd          }t/          j        dd          }t/          j        dd          }t/          j        d          }t/          j        d          }|t
          j        d<   |                    |||t*          |	         ||t,          |         d |         t,          |         d |                   }t          j        ||          }|t
          j        d<   t          j        |          }|                     ||j                   | 	                    |j
        |           | 	                    |j        |           | 	                    |j        |           | 	                    |j        t*          |	                    | 	                    |j        |           | 	                    |j        |           t5          | |dt,          |         d |                    t5          | |d	t,          |         d |                    8Zv|t
          j        d<   !d S )
Nr  r   r  r  r   r  )r+   rX  r]  r,   r  ra   rR  r-   rR  r-   )rx  r0  r1  r   r.   r  r2  r4  r3  r@  r+   rX  r]  r,   r  ra   rR  r-   r   r  r5  r  r9  r.  	randranger  r(   )r   r6  r.   r7  r  r)  combinationsdumperloaderrirL  fitir+   rt  rs  capsra   r   r   s                       r   r:  zContextAPItests.test_picklez  s   62Q677 9	1 9	1El*G+i0K &*\CK	"		AV\!U3344AQVQV,,,QVQV,,,QVQV,,,QZ444QZ444QWag...QWag...QWag... 01>QFQF++1vhL". "Z "Z&}55 !Z !ZEB!*>&+A!B!B  Z  ZA%.~f/E%F%F Z ZEB#)#3As#;#;D#)#3D!#<#<D#)#3As#;#;D#)#3A#6#6D$*$4Q$7$7E 6<CK	2 &'+$T+8+<+/u(6v(>ss(C(6v(>ss(C !/ ! !A !'Q 6 6A 6<CK	2 &QA 11!V^DDD ,,QVT::: ,,QVT::: ,,QVT::: ,,QZr9JKKK ,,QZ>>> ,,QWe<<<*4G^F=STWUWTW=XYYY*4G^F=STWUWTW=XYYYY?Z Z!ZF &1CK	""s9	1 9	1r!   c                     | j         j        }|                      |d          dd |d          di g           |                      |d          dddi g           d S )Nr  r  r  )r  r  )r   r   assertInassertNotInrg  s     r   test_equality_with_other_typesz.ContextAPItests.test_equality_with_other_types  sh    ,&ggbkkCggbkk5"#EFFFsC&;<<<<<r!   c                    | j         j        }| j         j        } |            }|                                }|                     t          |          t          |                     |                     t          |j                  t          |j                             |                     t          |j                  t          |j                             t          |j        	                                          }t          |j        	                                          }| 
                    ||           | 
                    |j        |j                   d S r   )r   r   r.   rn   rT  rC  rR  r-   r   keysr@  )r   r   r.   r  r   k1k2s          r   	test_copyzContextAPItests.test_copy  s    ,&,&GIIFFHHBqEE2a55)))BqwKKAG555BqwKKAG555    R   !'*****r!   c                 v    | j         j        } |            }|                     t          t          |d           d S )N_clamp)r   r.   rj  r3  r"   r   r.   r  s      r   test__clampzContextAPItests.test__clamp  s9     ,&GII.'1h?????r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S Nru  r  )r   r   r.   r  r@  rj  r2  r   r   r.   r  r   s        r   test_abszContextAPItests.test_abs  z    ,&,&GIIEE''"++rA&&&)QUD11111r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S Nr  r  )r   r   r.   r   r@  rj  r2  r  s        r   test_addzContextAPItests.test_add      ,&,&GIIEE''!**ggajj))q!a(((wwqzz1--q111q''!**--q111)QUC333)QUAs33333r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r$  r@  rj  r2  r  s        r   test_comparezContextAPItests.test_compare      ,&,&GIIIIggajj''!**--1a!,,,771::q1115551ggajj111555)QYQ777)QY377777r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   ri   r@  rj  r2  r  s        r   test_compare_signalz#ContextAPItests.test_compare_signal     ,&,&GIIWWQZZ44))!Q//333))''!**a88!<<<))!WWQZZ88!<<<)Q%5sA>>>)Q%5q#>>>>>r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   rk   r@  rj  r2  r  s        r   test_compare_totalz"ContextAPItests.test_compare_total  s    ,&,&GIIOOGGAJJ

33A..222Q77;;;GGAJJ77;;;)Q_c1===)Q_a=====r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   rm   r@  rj  r2  r  s        r   test_compare_total_magz&ContextAPItests.test_compare_total_mag  s   ,&,&GII

GGAJJ77,,Q22A666,,WWQZZ;;Q???,,Q

;;Q???)Q%8#qAAA)Q%8!SAAAAAr!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   rq   r@  rj  r2  r  s        r   test_copy_abszContextAPItests.test_copy_abs  sz    ,&,&GIIJJwwr{{##B+++)QZ66666r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   ro   r@  rj  r2  r  s        r   test_copy_decimalz!ContextAPItests.test_copy_decimal%  |    ,&,&GIINN772;;''++Q///)Q^T:::::r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   rs   r@  rj  r2  r  s        r   test_copy_negatez ContextAPItests.test_copy_negate.  |    ,&,&GIIMM''"++&&r**A...)Q]D99999r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S )Nr  r  r  r  )r   r   r.   ru   r@  rj  r2  r  s        r   r  zContextAPItests.test_copy_sign7  s    ,&,&GIIKK

GGBKK00Q++Q///WWQZZ44a888Q44a888)Q[#r:::)Q[!T:::::r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S Nr  r  r  r  )r   r   r.   r#  r@  rj  r2  r  s        r   test_dividezContextAPItests.test_divideC      ,&,&GIIHHWWQZZ,,!Q+++''!**a00!444!WWQZZ00!444)QXsA666)QXq#66666r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   rw   r@  rj  r2  r  s        r   test_divide_intzContextAPItests.test_divide_intO      ,&,&GIILLWWQZZ00a++Q///ggajj!44a888a44a888)Q\3:::)Q\1c:::::r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r.  r@  rj  r2  r  s        r   test_divmodzContextAPItests.test_divmod[  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S Nr  r-  )r   r   r.   rZ  r@  rj  r2  r  s        r   test_expzContextAPItests.test_expg  r  r!   c           	      ,   | j         j        }| j         j        } |            }|                     |d           |d           |d                    }|                     |                    ddd          |           |                     |                     |d          dd          |           |                     |                    d |d          d          |           |                     |                    dd |d                    |           |                     |                     |d           |d          d          |           |                     t          |j        ddd           |                     t          |j        ddd           |                     t          |j        ddd           |                     t          |j         |d           |d          d	           |                     t          |j         |d
           |d          d           |                     t           |d          j         |d          d	           |                     t           |d
          j         |d          d           d S )Nr  r  r  r  rJ  4r  r   znot a decimalr  r  gZd;O?)r   r   r.   r  r@  rj  r2  r  s        r   test_fmazContextAPItests.test_fmap  sr   ,&,&GIIEE''!**ggajj''!**55q!Q+++wwqzz1a00!444q''!**a00!444q!WWQZZ00!444wwqzz771::q991===)QUCA666)QUAsA666)QUAq#666 	)QU!'*--wwqzz?	L 	L 	L)QU!'!**ggfoou	> 	> 	> 	)WWZ%8%8%<!'!**o	7 	7 	7)WWQZZ^!'&//5	2 	2 	2 	2 	2r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r}   r@  rj  r2  r  s        r   test_is_finitezContextAPItests.test_is_finite  z    ,&,&GIIKK$$R!,,,)Q[$77777r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_is_infinitez ContextAPItests.test_is_infinite  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_is_nanzContextAPItests.test_is_nan  sz    ,&,&GIIHHWWR[[!!"q))))QXt44444r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_is_normalzContextAPItests.test_is_normal  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_is_qnanzContextAPItests.test_is_qnan  z    ,&,&GIIIIggbkk""2***)QY55555r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_is_signedzContextAPItests.test_is_signed  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_is_snanzContextAPItests.test_is_snan  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_is_subnormalz!ContextAPItests.test_is_subnormal  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_is_zerozContextAPItests.test_is_zero  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r  r@  rj  r2  r  s        r   test_lnzContextAPItests.test_ln  sz    ,&,&GIIDDb1%%%)QT400000r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   
test_log10zContextAPItests.test_log10  z    ,&,&GIIGGGGBKK  a((()QWd33333r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r  r@  rj  r2  r  s        r   	test_logbzContextAPItests.test_logb  z    ,&,&GIIFF772;;Q''')QVT22222r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   rc   r@  rj  r2  r  s        r   test_logical_andz ContextAPItests.test_logical_and      ,&,&GIIMM''!**ggajj11q!,,a000wwqzz155q999q''!**55q999)Q]C;;;)Q]As;;;;;r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S )Nr  r  )r   r   r.   ry   r@  rj  r2  r  s        r   test_logical_invertz#ContextAPItests.test_logical_invert  s    ,&,&GIIWWT]]++))$//333)Q%5v>>>>>r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_logical_orzContextAPItests.test_logical_or  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_logical_xorz ContextAPItests.test_logical_xor  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r  r@  rj  r2  r  s        r   test_maxzContextAPItests.test_max#  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_max_magzContextAPItests.test_max_mag/  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r  r@  rj  r2  r  s        r   test_minzContextAPItests.test_min;  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_min_magzContextAPItests.test_min_magG  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   minusr@  rj  r2  r  s        r   
test_minuszContextAPItests.test_minusS  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r2  r@  rj  r2  r  s        r   test_multiplyzContextAPItests.test_multiply\      ,&,&GIIJJwwqzz771::..Aq))1---GGAJJ22A666Awwqzz22A666)QZa888)QZC88888r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_next_minuszContextAPItests.test_next_minush  s|    ,&,&GIILL%%b))1---)Q\488888r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_next_pluszContextAPItests.test_next_plusq  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_next_towardz ContextAPItests.test_next_towardz  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_normalizezContextAPItests.test_normalize  r  r!   c                    | j         j        }| j         j        } |            }|                     |                    d          |                     |d                               |                     |                    d          |                     |d                               |                     |                    d          |                     |d                               d S )Nrn  r   rq  )r   r   r.   r@  rg   )r   r   r.   r  s       r   test_number_classz!ContextAPItests.test_number_class  s    ,&,&GII,,annWWS\\.J.JKKK**ANN771::,F,FGGG,,annWWS\\.J.JKKKKKr!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   plusr@  rj  r2  r  s        r   	test_pluszContextAPItests.test_plus  r  r!   c                    | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     |                     |d           |d                    |           |                     t          |j        dd           |                     t          |j        dd           |                     |                    ddd          d           d S )	Nr  r  r  r  rw  r  r  )modulor\  r  )r   r   r.   powerr@  rj  r2  r  s        r   
test_powerzContextAPItests.test_power  sX   ,&,&GIIGGGGAJJ

++A***Q//333GGAJJ//333WWQZZ88!<<<)QWc1555)QWa555Q!44a88888r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r  r@  rj  r2  r  s        r   rZ  zContextAPItests.test_quantize  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   	remainderr@  rj  r2  r  s        r   test_remainderzContextAPItests.test_remainder  s    ,&,&GIIKK

GGAJJ//Q**A...WWQZZ33Q777Q

33Q777)Q[#q999)Q[!S99999r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_remainder_nearz#ContextAPItests.test_remainder_near  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r  r@  rj  r2  r  s        r   test_rotatezContextAPItests.test_rotate  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   	test_sqrtzContextAPItests.test_sqrt  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_same_quantumz!ContextAPItests.test_same_quantum  s    ,&,&GIINN771::wwqzz221--q111

A66:::771::66:::)Q^S!<<<)Q^Q<<<<<r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r  r@  rj  r2  r  s        r   test_scalebzContextAPItests.test_scaleb  r  r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   r  r@  rj  r2  r  s        r   
test_shiftzContextAPItests.test_shift   s    ,&,&GIIGGGGAJJ

++A***Q//333GGAJJ//333)QWc1555)QWa55555r!   c                 B   | j         j        }| j         j        } |            }|                     |d           |d                    }|                     |                    dd          |           |                     |                     |d          d          |           |                     |                    d |d                    |           |                     t          |j        dd           |                     t          |j        dd           d S r  )r   r   r.   subtractr@  rj  r2  r  s        r   test_subtractzContextAPItests.test_subtract  r  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_to_eng_stringz"ContextAPItests.test_to_eng_string  |    ,&,&GIIOOGGBKK((,,a000)Q_d;;;;;r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_to_sci_stringz"ContextAPItests.test_to_sci_string!  r"  r!   c                    | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           d S r  )r   r   r.   r   r@  rj  r2  r  s        r   test_to_integral_exactz&ContextAPItests.test_to_integral_exact*  s    ,&,&GII,,,,R00!444)Q%8$?????r!   c                 ^   | j         j        }| j         j        } |            }|                     |d                    }|                     |                    d          |           |                     t          |j        d           |                     t          |j        dd           d S )Nr  r-  r  )r   r   r.   r   r@  rj  r2  r  s        r   test_to_integral_valuez&ContextAPItests.test_to_integral_value3  s    ,&,&GII,,,,R00!444)Q%8$???)Q%8"cBBBBBr!   N)Gr   r_  r`  r
  r
   r   r   r  r  r  r:  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rZ  r  r  r  r  r  r  r  r  r!  r$  r&  r(  r   r!   r   r  r  S  s       9 9 9( !$_$.@AAA@ @ BA "! \@;1 ;1 ;1z= = =+ + +	@ 	@ 	@2 2 2
4 
4 
4
8 
8 
8
? 
? 
?
> 
> 
>
B 
B 
B7 7 7; ; ;: : :
; 
; 
;
7 
7 
7
; 
; 
;
7 
7 
72 2 22 2 248 8 8: : :5 5 58 8 86 6 68 8 86 6 6; ; ;6 6 61 1 14 4 43 3 3
< 
< 
<? ? ?
; 
; 
;
< 
< 
<
4 
4 
4
8 
8 
8
4 
4 
4
8 
8 
84 4 4
9 
9 
99 9 98 8 8
< 
< 
<8 8 8L L L3 3 39 9 9
9 
9 
9
: 
: 
:
? 
? 
?
7 
7 
73 3 3
= 
= 
=
7 
7 
7
6 
6 
6
9 
9 
9< < << < <@ @ @C C C C Cr!   r  c                       e Zd ZeZdS )CContextAPItestsNr  r   r!   r   r*  r*  =  r  r!   r*  c                       e Zd ZeZdS )PyContextAPItestsNr  r   r!   r   r,  r,  @  r  r!   r,  c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
ContextWithStatementc                 @   | j         j        }| j         j        } |            } |            5 } |            }d d d            n# 1 swxY w Y    |            }|                     ||d           |                     ||d           |                     ||d           d S )N!did not restore context correctlydid not copy the context __enter__ returned wrong context)r   r  r  r  assertIsNot)r   r  r  orig_ctx	enter_ctxset_ctx	final_ctxs          r   test_localcontextz&ContextWithStatement.test_localcontextG  s    \,
|0:<<\^^ 	#y jllG	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#JLL	h	+NOOO7,FGGGgy*LMMMMMs   AAAc                    | j         j        }| j         j        }| j         j        }| j         j        } |            } |d          } ||          5 } |            }d d d            n# 1 swxY w Y    |            }|                     ||d           |                     |j        |j        d           |                     ||d           |                     ||d           d S )Nr  r+   r0  zdid not set correct contextr1  r2  )r   r.   r  r  r  r@  r+   r3  )	r   r.   r  r  r4  new_ctxr5  r6  r7  s	            r   test_localcontextargz)ContextWithStatement.test_localcontextargT  s)   ,&\,
|0|0:<<'r"""\'"" 	#i jllG	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#JLL	h	+NOOOw|5RSSS'+EFFFgy*LMMMMMs   A))A-0A-c                 2   | j                             dt          dddd          5 }|                     |j        d           |                     |j        | j         j                   |                     |j        d           |                     |j        d           |                     |j        d           |                     |j	        d           d d d            n# 1 swxY w Y   | 
                    t          | j         j        d           | 
                    t          | j         j        d           | 
                    t          | j         j        d	
           | 
                    t          | j         j        d           | 
                    t          | j         j        d           | 
                    t          | j         j        d           | 
                    t          | j         j        d           | 
                    t          | j         j        d           | 
                    t          | j         j        d           | 
                    t          | j         j        d           | 
                    t          | j         j        d
           d S )Nr  i   r   r  )r+   r,   rX  r]  r  ra   )r^   rX  ru  r]  r  r  ra   r   rV  rR  r-   )r   r  r   r@  r+   r,   rX  r]  r  ra   rj  r2  r  r  s     r   test_localcontext_kwargsz-ContextWithStatement.test_localcontext_kwargse  s   \&&o2 ' 
 
 
	+ SXr***S\4<+GHHHSXs+++SXr***S\1---SY***
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 
	+ 	)T\%>"MMM*dl&?aHHH*dl&?bIII*dl&?!LLL*dl&?qIII)T\%>LLL)T\%>KKK)T\%>bIII)T\%>bIII)T\%>RHHH)T\%>RHHHHHs   B-CC#&C#c                    | j                                         }|j        }| j                             d          5 }|                     |j        d           |                     |j        |           d d d            n# 1 swxY w Y   | j                             d          5 }|                     |j        d           |                     |j        |           d d d            d S # 1 swxY w Y   d S )Nr  r:  r>  )r   r  r+   r  r@  )r   r  	orig_precctx2s       r   >test_local_context_kwargs_does_not_overwrite_existing_argumentzSContextWithStatement.test_local_context_kwargs_does_not_overwrite_existing_argument  sc   l%%''H	\&&B&// 	24TY+++SXy111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 \&&B&// 	24TY+++SXy111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s#   7A??BB%7C))C-0C-c           	         | j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        } |            }|                                  |d          } |            5 }	|                     |	j	        |j	                   |                     |	j
        |j
                   d|	j
        |<   d|	_        |                     |j        d           |                     ||	j        d           |                     |	j	        |                     ||          5 }
|                     |
j	        |j	                   |                     |
j
        |j
                   |                     ||
j         |d          d           |                     |
j	        |                    |                     |
j	        |                    ~
d d d            n# 1 swxY w Y   |                     |	j	        |                    ~	d d d            n# 1 swxY w Y   |                     |j        d           |                     |j	        |                    |                     |j	        |                    |                     |j	        |                    |                     |j	        |                    d S )N  r@  Tz0e-999z3.4e200r  )r   r   r.   r  r  r   r   r/  r@  rR  r-   rX  rT  rj  r   r#   r  r%  )r   r   r.   r  r  r   r   r4  r;  r+  r)  s              r   test_nested_with_statementsz0ContextWithStatement.test_nested_with_statements  s   ,&,&\,
|0,&<(:<<'s###\^^ 	rRXx~666RXx~666 $BHWBGt444gr'8(CCCOOBHW-...g&& "  7=999  7=999!!(BHggi6H6H!LLL  '!2333 2333               RXh/000!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	" 	HM400001111222w/000x011111s8   =B4H1B(G%H%G)	)H,G)	-$HH!$H!c           	      8   | j         j        } |            5 }~ |            5 }~ |            5 }~ |            5 }~d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S r   r   r  r   r  r+  r)  r*  c4s         r   test_with_statements_gc1z-ContextWithStatement.test_with_statements_gc1  s   |0\^^ 	r 2!\^^ r% 2                                          	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sy   BA7A A		A 	AA AA A7 A$$A7'A$(A7+B7A;	;B>A;	?BBBc           	      >   | j         j        } |            5 } ||          5 }~ ||          5 }~ ||          5 }~~d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S r   rO  rP  s         r   test_with_statements_gc2z-ContextWithStatement.test_with_statements_gc2  s   |0\^^ 	rb!! R!\"%% %b)) R                                          	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sz   BA:A#A	 A#AA#AA#A:#A''A:*A'+A:.B:A>	>BA>	BBBc           	         | j         j        }| j         j        }| j         j        }| j         j        } |            5 }~ |d          } ||            ||          5 }~|                     |j        d           ~ |d          } ||           ~|                      |            j        d            |d          }	 ||	           |                      |            j        d            ||	          5 }
~	|                     |
j        d           ~
 |d          } ||           ~|                      |            j        d            |            5 }|                     |j        d           ~d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr  r:  r  r  r  )r   r.   r  r  r3   r@  r+   )r   r.   r  r  r3   r+  n1r)  n2n3r*  n4rQ  s                r   test_with_statements_gc3z-ContextWithStatement.test_with_statements_gc3  s   ,&|0\,
\,
\^^ 	raBJrNNNb!! R  !,,,W!___
2  !2A666W!___
2  !2A666!\"%% 
$$RWa000 aBJrNNN$$ZZ\\%6:::% 2((!444              
 
 
 
 
 
 
 
 
 
 
 
 
 
 
              		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   $GBF7=A#F  F		=F 	FF FF F7 F$$F7'F$(F7+G7F;	;G>F;	?GGGN)r   r_  r`  r8  r<  rE  rI  rM  rR  rT  rZ  r   r!   r   r.  r.  C  s        N N NN N N"I I I82 2 2!2 !2 !2F
 
 

 
 
    r!   r.  c                       e Zd ZeZdS )CContextWithStatementNr  r   r!   r   r\  r\    r  r!   r\  c                       e Zd ZeZdS )PyContextWithStatementNr  r   r!   r   r^  r^    r  r!   r^  c                   <    e Zd Zd Zd Zed             Zd Zd ZdS )ContextFlagsc                 v     j         j        } j         j        } j         j        } j         j        } j         j        } j         j        } j         j        } fd} |dddt          g g           }	|	j	         |d          gf|	j
         |d          gf|	j         |d           |d	          gf|	j         |d           |d	          gf|	j         |d           |d	          gfg}
|g|g|g|g|g|||||gg}|
D ]8\  }}|	                                  || }d
 |	j                                        D             }|D ]}|	                                 |D ]} ||	|            || }t#          |          }|D ]}||vr|                    |           |                    t(                     d |	j                                        D             }|                    t(                                          ||dd|d|dz                                   ||dd|d|z              :d S )Nc                     j         t          k    rd| j        |<   | j        |         r|d S |                     |           d S NT)r   r   rR  r-   _raise_error)r&   flagr   s     r   raise_errorz7ContextFlags.test_flags_irrelevant.<locals>.raise_error  sV    |q  &*d#=& J  $$T*****r!   r*   r:  r   )r+   rX  r]  r,   r-   rR  z100E-425000010r  ru  z
9.87654321c                     g | ]	\  }}||
S r   r   r   kr   s      r   r'  z6ContextFlags.test_flags_irrelevant.<locals>.<listcomp>  s!    >>>41aA>Q>>>r!   r+  c                     g | ]	\  }}||
S r   r   rh  s      r   r'  z6ContextFlags.test_flags_irrelevant.<locals>.<listcomp>'  s!    EEE31Q1EQEEEr!   z=operation produces different answers depending on flags set: z	expected z, got r  z9operation raises different flags depending on flags set: )r   r   r.   r   r   r   r   r   r/   re   r   r   r2  r  r/  rR  r  rV  r8  r>  rC  r@  )r   r   r.   r   r   r   r   r   rf  r&   
operationsflagsetsfnr  rE  rR  extra_flagsre  new_ansexpected_flags	new_flagss   `                    r   test_flags_irrelevantz"ContextFlags.test_flags_irrelevant  s    ,&,&,&,&L*	,&L*		+ 	+ 	+ 	+ 	+ 'qI#2"BH H H
 ^gg&67789\GGAJJ<([77<00'',2G2GHI 5 5ww|7L7LMN 5 5ww|7L7LMN
 Iy9+y9+gy'9EG # 	W 	WHB!!!"d)C>>7=#6#6#8#8>>>E' W W##%%%' / /DK...."d) "&e' 4 4D>11&--d333###+++ FE'-*=*=*?*?EEE	2&&&  g!`!`;>33!H"IJ J J   N"]"];I>>99"U#VW W W W+W	W 	Wr!   c                 &   | j         j        }| j         j        }| j         j        } |            }|                     |j        |j                   |                     |j        |j                   |j        |_        |                     |j        |j                   |                     |j        |j                   d|j        |<   |j        |_        |                     |j        |j                   |                     |j        |j                   i }|                    |j                   |                     ||j                   |                     |j        |           d||<   |                     ||j                   |                     |j        |           |di}|                     ||j                   |                     |j        |           dg}|                     ||j                   |                     |j        |           d S )NTFr  )	r   r.   r   r   rT  rR  r-   r@  update)r   r.   r   r   r  r   s         r   test_flag_comparisonsz"ContextFlags.test_flag_comparisons1  s   ,&,&,&GII 	AGQW---AGQW---'!'***!'***'!'***!'***	AG$$$!$$$'
Aqw'''AGQ''' UOAqw'''AGQ'''GAqw'''AGQ'''''r!   c                    | j         j        }| j         j        }| j         j        } |            5 }|                     |j        |                    |                                 |                      |d          d           |                     |j	        |                    |                                 |                     |
                    d          d           |                     |j	        |                    |                                 |                    d          }|                     |j	        |                    |                     |d           |                     |j	        |                    |                                 |                    d          }|                     |j	        |                    |                     |d           |                     |j	        |                    d|j        |<   |                                 |                     ||d           |                     |j	        |                    |                                 |                     ||j
        d           |                     |j	        |                    |                                 |                    d          }|                     |j	        |                    |                                 |                    d          }|                     |j	        |                    d d d            d S # 1 swxY w Y   d S )Ng      @T)r   r   rt  r  r%  r-   r/  r@  r#   rR  r   r  rR  rj  )r   r   rt  r  r  r  s         r   test_float_operationz!ContextFlags.test_float_operationW  s   ,&4|0\^^ .	6qQW^4555 MMOOOWWS\\3///OOAGN3444MMOOOQ--c22C888OOAGN3444 MMOOO""3''AQW^4555Q$$$OOAGN3444MMOOO++C00AQW^4555Q$$$OOAGN3444 '+AGN# MMOOOngs;;;OOAGN3444MMOOOna.>DDDOOAGN3444 MMOOO""3''AQW^4555MMOOO++C00AQW^4555].	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6 .	6s   LMM	Mc                    	
  j         j         j         j        } j         j         j         j        }d fd		 d           d          
dd d           d          dd	 d
           d          t          d          t          d          d	
fd	}d fd	} |            } ||          5 }                     |j                             ||d             ||d            d|j        <    ||            ||           d d d            d S # 1 swxY w Y   d S )Nc                 
   |                                  t          | |          }|k    r                    |||           n                     ||          d                               |j                            d S rc  )r/  r"   rj  r  r#   rR  )r  r\  r'   r&   signalr   rt  r   s         r   assert_attrz7ContextFlags.test_float_comparison.<locals>.assert_attr  s    !!!4  A''!!&!Q////aaddD)))OOGM.9:::::r!   r_  r`  rb  ra  r?  r  r  rQ  r  r  r  r  c                    dD ]} || |           dD ]} || |            d| d             d| d             d| d             d| d             d| d             	
d| d             d| d             d| d              d          dd| d             	d| d             
d| d              d          t          d          d| d            d S )	N)r  r  )r  r  r  r  r  r  r}  r  )r  )r  rz  r'   r   r{  big_dbig_finf_dinf_f	neg_inf_d	neg_inf_f
neg_zero_d
neg_zero_fsmall_dsmall_fzero_dzero_fs      r   doitz0ContextFlags.test_float_comparison.<locals>.doit  s   * = =GUD!V<<<<* = =E7D!V<<<< K(At<<<K
J!TBBBK
FHa>>>K
Ha>>>K!T:::K	9h4@@@Kuh4888 K!T:::KXq$???K	5(At<<<Ky(At<<<Keh4HHHHHr!   c                    |                                   t          d d          g          }                    t          |          d                               | j                            |                                   |r(                    |t          d d          g           nt          d d          g          }                    | j                            |                                   d d          dfv }                    | j                            |                                   d d          dddiv }                    | j                            d S )	Nr?  z100.0r  r  r  g      $@r  r\  )r/  r   r@  lenr#   rR  rj  sorted)r  rz  r   r\  r   rt  r   s       r   test_containersz;ContextFlags.test_float_comparison.<locals>.test_containers  sU   MMOOOUGGG,,-..ASVVQ'''OOAGN3444MMOOO 4!!&&32HIIIID''&//233OOAGN3444MMOOO#..AOOAGN3444MMOOOc#66AOOAGN344444r!   )rz  Tr   )r   r   r.   rt  r  r  r%  r-   )r   r.   r  r  r  r  r  r   rt  r{  r}  r~  r  r  r  r  r  r  r  r  r  r  s   `      @@@@@@@@@@@@@@@r   test_float_comparisonz"ContextFlags.test_float_comparison  sn   ,&,&4|0	; 	; 	; 	; 	; 	; 	; '&//WV__


##GK((	e&MM		I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I<	5 	5 	5 	5 	5 	5 	5 	5* WYY\" 	6QW^4555D4    OAd++++&*AGN#D>****OAn5555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s    AEEEc                    | j         j        }| j         j        }| j         j        }| j         j        } |            }|                     |j        |                    |                     |j        |                    |                                 d|j        |<   d|j        |<   | 	                    |j        |                    | 	                    |j        |                    d S rc  )
r   r   r.   r   rt  r%  rR  r-   clear_trapsr#   )r   r   r.   r   rt  r&   s         r   test_float_operation_defaultz)ContextFlags.test_float_operation_default  s    ,&,&,&3'))~6777~6777!%g(,n%n5666g./////r!   N)	r   r_  r`  rr  ru  r   rw  r  r  r   r!   r   r`  r`    sy        @W @W @WD$( $( $(L 36 36 36jY6 Y6 Y6v0 0 0 0 0r!   r`  c                       e Zd ZeZdS )CContextFlagsNr  r   r!   r   r  r    r  r!   r  c                       e Zd ZeZdS )PyContextFlagsNr  r   r!   r   r  r    r  r!   r  c                       e Zd ZdZd Zd ZdS )SpecialContextszTest the context templates.c           
         | j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j	        }	t          | |d|||||	g            |                                            }
|j        }|j        }d }	 dx|_        |_        ||fD ]H} ||            |            }|                     ||           |                     |j        d           In# t          $ r}|j        }Y d }~nd }~ww xY w||_        ||_         ||
           |r|d S # ||_        ||_         ||
           |r|w xY w)Nr-   i  )r   BasicContextExtendedContextr  r3   r   r   r   r   r   r(   rn   r+   r3  r@  	Exceptionr   )r   r  r  r  r3   r   r   r   r   r   savecontextbasic_context_precextended_context_precextemplater  r)  s                    r   test_context_templatesz&SpecialContexts.test_context_templates  s   |0,6\,
\,
<84<(L*	,&t\7~xGL	
 	
 	
 !jll''))). / 4	7::L 4(/9 . .
8$$$JLL  H---  ----	.
  	 	 	BBBBBB	 !3L#8O J{###   !3L#8O J{### s1   1AD E
 
D(D#E
 #D((E
 
E)c                 N   | j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| j         j        }| 	                    |j
        d           | 	                    |j
        d           t          | |d|||g            |                                            }	|j
        }
d }	  |            }|j
        }d|_
         |            }| 	                    |j
        |            ||            |            }|                     ||           | 	                    |j
        d           n# t          $ r}|j        }Y d }~nd }~ww xY w|
|_
         ||	           |r|d S # |
|_
         ||	           |r|w xY w)Nr*   r-   i  )r   r<  r  r  r  r3   r   r   r   r@  r+   r(   rn   r3  r  r   )r   r<  r  r  r  r3   r   r   r   r  default_context_precr  r  saveprecr)  s                  r   test_default_contextz$SpecialContexts.test_default_context%  s   4|0,6\,
\,
<84<(*A...-q111t^W~x8	
 	
 	
 !jll''))-2	
AvH"%N
AQVX...J~&&&
AQ///QVS)))) 	 	 	BBBBBB	 #7NJ{###   #7NJ{### s1   BE F 
E1 E,'F ,E11F F$N)r   r_  r`  ra  r  r  r   r!   r   r  r    s9        %%" " "H' ' ' ' 'r!   r  c                       e Zd ZeZdS )CSpecialContextsNr  r   r!   r   r  r  N  r  r!   r  c                       e Zd ZeZdS )PySpecialContextsNr  r   r!   r   r  r  Q  r  r!   r  c                       e Zd Zd ZdS )ContextInputValidationc           	         | j         j        }| j         j        }|                                }dD ]}}t	          ||d           |                     t          ||          d           |                     t          t          ||d           |                     t          t          ||d           ~t	          |dd           |                     t          |d          d           |                     t          t          |dd           |                     t          t          |dd           |                     t          t          |d	d           |                     t          t          |d	d
           |                     t          t          |d	d           |                     t          t          |d	d           dD ]m}|                     t          t          ||d           |                     t          t          ||d           |                     t          t          ||g d           n|                     t          t          |dd           |                     t          t          |dg            |                     t          t          |di            |                     t          t          |dddi           dD ]#}|                     t          |j        |           $|                     t          t          |d
           |                     t          t          |d
           |                     t          |d           |                     t          |d           |                     t          |d           |                     t          |d           |                     t          |dg           |                     t          |dg           |                     t          |d           |                     t          |d           d S )Nr+   r]  r  ru  r  rX  r  r  r  r  r  r,   r*   r  r  ra   r  rs  r  rR  r-   r   r   )r+   r]  rX  r,   r  ra   rR  r-   rV  rB  rA  r  rC  QrD  r   r  )r  r   )r   r.   r<  rn   r/  r@  r"   rj  r  r2  r3  KeyError__delattr__)r   r.   r<  r  r'   s        r   test_invalid_contextz+ContextInputValidation.test_invalid_contextV  s   ,&4!! % 	B 	BDAtV$$$WQ--v666j'1dB???i!T5AAAA 	67###F++W555*gq&!<<<)WaAAA)WaR@@@)WaQ???)WaSAAA)WaUCCC * 	D 	DDj'1dB???j'1dA>>>i!T777CCCC 	.'1fcBBB 	)Wa"===(GQ<<<(GQ-a0	2 	2 	2' 	C 	CDnamTBBBB 	)Wa333)Wa333 	)Wv>>>)Wu===*gQ777*g;;;(GC5999(GC5999 	)WE:::)WE:::::r!   N)r   r_  r`  r  r   r!   r   r  r  T  s#        :; :; :; :; :;r!   r  c                       e Zd ZeZdS )CContextInputValidationNr  r   r!   r   r  r    r  r!   r  c                       e Zd ZeZdS )PyContextInputValidationNr  r   r!   r   r  r    r  r!   r  c                       e Zd Zd ZdS )ContextSubclassingc                 	   | j         j        }j        j        }j        }j        }j        }j        }j        }j	        }j
        }	 G fdd          }
             } |
            }dD ]4}|                     t          ||          t          ||                     5 | j        t          |
fi ddi  |
d          }|                     |j        d           |                     |	|j         |d          d	            | j        t"          |
fi d
di  |
t$          d          }|                     |j        t$                     |                     |                     |d                    d            | j        t          |
fi ddi  |
dd          }|                     |j        d           |                     |d           |d                    }|                     | |d                     |||||fD ]"}|                     |j        |                    # | j        t          |
fi ddi  |
dd          }|                     |j        d           |                     ||j         |d           |d                     | j         t4          k    r(|||fD ]"}|                     |j        |                    # | j        t          |
fi ddi  |
d	          }|                     |j        d	           |                    d          }|                     |                    |          d            | j        t          |
fi ddi  |
dd           }|                     |j        d           |                     |d                    }|                     t?          |          d!            | j        t"          |
fi d"di  |
||g#          }||fD ]"}|                     |j        |                    #|                                  tB                   D ]"}| "                    |j        |                    # | j        t"          |
fi d$di  |
||g%          }||fD ]"}|                     |j#        |                    #|$                                 tB                   D ]"}| "                    |j#        |                    #d S )&Nc                   $    e Zd Z	 	 	 d fd	ZdS )>ContextSubclassing.test_context_subclassing.<locals>.MyContextNc	                    	                     |            ||| _        ||| _        ||| _        ||| _        ||| _        ||| _        8t          t                    rfdt          
         z   D             | _
        :t          t                    rfdt          
         z   D             | _        d S d S )Nc                     i | ]}||v S r   r   )r   r   rR  s     r   
<dictcomp>z[ContextSubclassing.test_context_subclassing.<locals>.MyContext.__init__.<locals>.<dictcomp>       Y Y YAAJ Y Y Yr!   c                     i | ]}||v S r   r   )r   r   r-   s     r   r  z[ContextSubclassing.test_context_subclassing.<locals>.MyContext.__init__.<locals>.<dictcomp>  r  r!   )r  r+   r,   rX  r]  r  ra   r  rV  r9  rR  r-   )r   r+   r,   rX  r]  r  ra   rR  r-   r.   r   s          ``r   r  zGContextSubclassing.test_context_subclassing.<locals>.MyContext.__init__  s       &&&# $DI'$,DM# $DI# $DI'$,DM$!&DJ$!%.. Z Y Y Y Y9PSX9X Y Y Y!&DJ$!%.. Z Y Y Y Y9PSX9X Y Y Y!&DJJJ %$r!   )NNNNNNNNr  )r.   r   s   r   	MyContextr    sA        IM@D%)' ' ' ' ' ' ' ' 'r!   r  r+   r,   rX  r]  r  ra   rR  r-   r+   ru  r  r:  9e2r   r,   XYZ)r,   r+   ri  r*   rX  rw  )rX  r+   z1e-99z2.234e-2000r?  r]  )r]  r+   1e99z
2.234e2000r  rA  1E222z1e+222ra   r  c   )ra   r]  z!1.000000000000000000000000000E+99rR  rC  r-   rD  )%r   r   r.   r   r   r   r   r   r   r   r   r@  r"   rj  r  r+   r  r2  r   r,   r  rX  r   r#   rR  r]  r   r  r   r   ra   r;  r/  r9  r%  r-   r  )r   r   r   r   r   r   r   r   r   r   r  r  r   r'   r  rz  r.   r   s                   @@r   test_context_subclassingz+ContextSubclassing.test_context_subclassing  s   ,/// //#/%	%	"3	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'4 GIIIKK' 	A 	ADWQ--wq$/?/?@@@@ 	*i??F2;???I1###*AJJJJ 	)YEE:e2DEEEIz222Z000//333 	*i>>F1:>>>I2A&&&$$$EE'''""GGM$:$:;;GGENN+++	9gwG 	- 	-FOOAGFO,,,, 	*i??F2;???I11%%%###(AE776??GGL<Q<QRRR<1"Hg6 1 10000 	*iCCJr?CCCIq!!!Q'''W%%++X666 	*i??GA;???IAB'''!$$$FF776??##Q!DEEE 	)YBB75/BBBIWn5666/ 	- 	-FOOAGFO,,,,	$W- 	. 	.FQWV_---- 	)YBB75/BBBIWn5666/ 	- 	-FOOAGFO,,,,	$W- 	. 	.FQWV_----	. 	.r!   N)r   r_  r`  r  r   r!   r   r  r    s(        i. i. i. i. i.r!   r  c                       e Zd ZeZdS )CContextSubclassingNr  r   r!   r   r  r    r  r!   r  c                       e Zd ZeZdS )PyContextSubclassingNr  r   r!   r   r  r    r  r!   r  c                        e Zd Zd Zd Zd ZdS )CheckAttributesc                    |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j        t          j                   |                     t          j        du pt          j        du            |                     t          j        du pt          j        du            |                      t          j	        t          j	                   |                      t          t                    t          t                               d S )NTF)r@  r   rU  r  r   rp  rq  r#   r=  __version__dirr   s    r   test_module_attributesz&CheckAttributes.test_module_attributes  s     	QZ000QZ000QZ000ak222$.I!.E2IJJJ$.I!.E2IJJJ666QQ(((((r!   c                 D   d t          t                                                    D             }d t          t                                                    D             }|                     t          |          t          |          z
  t                                 d S )Nc                 D    g | ]}d |v s|                     d          |S __rL  r  r   r   s     r   r'  z;CheckAttributes.test_context_attributes.<locals>.<listcomp>   -    OOO1DAIIQ\\#=N=NIQIIIr!   c                 D    g | ]}d |v s|                     d          |S r  r  r  s     r   r'  z;CheckAttributes.test_context_attributes.<locals>.<listcomp>!  r  r!   )r  r   r.   r  r@  r   r   r  r  s      r   test_context_attributesz'CheckAttributes.test_context_attributes  sx    OOAIIKK((OOOOOAIIKK((OOOQ#a&&#%%00000r!   c                 H   d t          t                              d                    D             }d t          t                              d                    D             }|                     t	          |          t	          |          z
  t	                                 d S )Nc                 D    g | ]}d |v s|                     d          |S r  r  r  s     r   r'  z;CheckAttributes.test_decimal_attributes.<locals>.<listcomp>&  -    PPP1TQYYall3>O>OYQYYYr!   r*   c                 D    g | ]}d |v s|                     d          |S r  r  r  s     r   r'  z;CheckAttributes.test_decimal_attributes.<locals>.<listcomp>'  r  r!   )r  r   r   r@  r   r  s      r   test_decimal_attributesz'CheckAttributes.test_decimal_attributes$  s|    PPAIIaLL))PPPPPAIIaLL))PPPQ#a&&#%%00000r!   N)r   r_  r`  r  r  r  r   r!   r   r  r    sA        ) ) )1 1 11 1 1 1 1r!   r  c                   \    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )Coveragec                 D   | j         j        }|                      |d                                          d           |                      |d                                          d           |                      |d                                          d           d S )N	1234e9999i'  r  r   r  )r   r   r@  rn  rg  s     r   test_adjustedzCoverage.test_adjusted,  s    ,&--6688%@@@0022A6660022A66666r!   c                    | j         j        }| j         j        } |d                                          }|                     |d            |            }|                     |d                    }|                     |d           d S )Nr*   )r   r   r  rp  r@  )r   r   r  r  r  s        r   test_canonicalzCoverage.test_canonical4  s    ,&\,
GAJJ  ""AJLLKK

##Ar!   c                 J   | j         j                                        }d|_        d|_        d|_        t          |_        d|_        d|_	        t          | j                  D ]}d|j        |<   d|j        |<   |                                }d}|                     ||           d S )Nr   r:  r   r  Fz{Context(prec=425000000, rounding=ROUND_HALF_DOWN, Emin=-425000000, Emax=425000000, capitals=0, clamp=1, flags=[], traps=[]))r   r<  rn   r+   r]  rX  r   r,   r  ra   r9  rR  r-   __repr__r@  )r   r  r,  r   r   s        r   test_context_reprzCoverage.test_context_repr?  s    L',,..$

!$,/ 	! 	!C AGCL AGCLLJJLL" 	Ar!   c                 T   | j         j        }| j         j        } |            5 }d|_        d|_        d|_        |                     t           |d                    d           |                      |d          dz   d           |                      |d          dz  d	           |                      |d          d
z  d           |                      |d                               |d          d          d           | 	                     |d                              d
d          
                                d           |                     t           |d          d	d
          d	           |                      |d                                          d           | 	                     |d                                          d           | 	                     |d                                          d           |                      |d                                          d           |                      |d                                          d           |                      |d                                          d	           |                      |d                                          d           |                      |d           d           |                      |d          dz  d           |                      |d                                          d           |                      |d                                           |d                     |                      |d                                           |d                     |                      |d                                          d           |                      |d          
 d           |                      |d          d
z  d           |                      |d          d
z
  d           |                      |d                                          d           |                      |d                                                     |                      |d                                                     |                      |d                                                     |                      |d                                                     |                      |d                                                     |                      |d                                                     |                      |d                                                     d d d            n# 1 swxY w Y    |            5 }d|_        d d!z  } ||           }|                                }|                     ||           |                                }|                     ||           |                      |d                    }|                     ||           d d d            d S # 1 swxY w Y   d S )"Nr  ru  z-10r  7r  r-  rw  r  r  z1.2rf  r}  Tz1.01r  F20580r  r  r*   z2E+1z-1E+1z+Normalr  z1.12345r  r  re  r  i  i  )!r   r   r  r+   r]  rX  r@  r  r  r  r   powrZ  r   r   r  r   r  ry   r   r   r   rg   r   r#   r{   r}   r   r   r   rq   rs   ru   )r   r   r  r  r  r  r	  s          r   r  zCoverage.test_implicit_contextR  st   ,&|0\^^ <	4qAFAFAF S00"555WWS\\A-q111WWT]]Q.222WWT]]a/333WWU^^//CCQGGGMM''%..,,Q2299;;TBBBSa33Q777WWV__0022A666MM''&//3355u===MM''&//6688$???WWT]]--//333WWT]]0022A666WWU^^0022A666WWT]]99;;Q???ggenn_b111WWS\\A-q111WWT]]5577;;;WWT]]4466HHHWWU^^55779I9IJJJWWT]]77999EEEggdmm^R000WWT]]Q.222WWT]]Q.222WWY//AACCQGGG OOGGCLL5577888OOGGCLL2244555OOGGCLL2244555OOGGFOO3355666OOGGDMM3355666OOGGCLL0022333OOGGCLL0022333y<	4 <	4 <	4 <	4 <	4 <	4 <	4 <	4 <	4 <	4 <	4 <	4 <	4 <	4 <	4~ \^^ 	#qAFAA

AQ"""AQ"""GGAJJ''AQ"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s%   V+WW!W/B!ZZ!$Z!c                 |   | j         j        }| j         j        }| j         j        }| j         j        } |            5 }t           |d          d          \  }}|                     | |d                     |                     | |d                     t           |d          d          \  }}|                     |                                o|                                           d|j	        |<   t           |d          d          \  }}|                     |                                o|                                           d|j	        |<   |
                                 t           |d           |d                    \  }}|                     |                                o|                                           |                     |j        |                    |
                                 t           |d          d	          \  }}|                     |                                o|                                           |                     |j        |                    |
                                 t           |d
          d
          \  }}|                     |                                o|                                           |                     |j        |                    d|j	        |<   |
                                 t           |d          d
          \  }}|                     |                                o|                                           |                     |j        |         o|j        |                    d d d            d S # 1 swxY w Y   d S )N10912837129r  10901935194r}  r  Fr  r  r      )r   r   r  r   r   r.  r@  r#   r   r-   r/  rR  r   )r   r   r  r   r   r  r  r  s           r   r  zCoverage.test_divmod  s_   ,&|0<84\^^ !	5q''-00$77DAqQ
 3 3444Q///''%..!,,DAqOOAHHJJ5188::666(-AG$%''%..!,,DAqOOAHHJJ5188::666(-AG$%MMOOO''%..''%..99DAqOOAHHJJ5188::666OOAG$45666MMOOO''%..#..DAqOOAMMOO:

;;;OOAG$45666MMOOO''!**a((DAqOOAHHJJ5188::666OOAG$45666&+AGN#MMOOO''"++q))DAqOOAMMOO:

;;;OOAG$45 4GN35 5 5A!	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5 !	5s   M)N11N58N5c                    | j         j        }| j         j        }| j         j        }| j         j        } |            5 }d|_        |                                 |                      |d          dz   |d                     |                     |j	        |                    d|_        d|_
        d|_        |                                 d|j        |<   |                      |d           |d	          z   |d
                     |                     |j	        |                    d d d            d S # 1 swxY w Y   d S )Nr  r  r  r^  r  ru  Fr  r  r  )r   r   r  r   r   r+   r/  r@  r#   rR  r]  rX  r-   )r   r   r  r   r   r  s         r   r  zCoverage.test_power  si   ,&|0<(,&\^^ 	/qAFMMOOOWWU^^s2GGFOODDDOOAGG,---AFAFAFMMOOO %AGHWWU^^wwu~~=wwu~~NNNOOAGH-...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   C.D66D:=D:c                 n   | j         j        }| j         j        }| j         j        } |            5 }d|_        d|_        d|_        d|j        |<    |d                               |d                    }| 	                    |
                                           d d d            d S # 1 swxY w Y   d S )Nr  ru  Fr  1e1)r   r   r  r   r+   r]  rX  r-   r  r#   r   r   r   r  r   r  r  s         r   rZ  zCoverage.test_quantize  s    ,&|0<8\^^ 	(qAFAFAF(-AG$%$$WWU^^44AOOAHHJJ'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   A.B**B.1B.c                     | j         j        }| j         j        } |            }|                      |d                                          d           |                     |                                d           d S )Nr  r  )r   r   r  r@  ro  r  s       r   
test_radixzCoverage.test_radix  so    ,&\,
JLL++--r222B'''''r!   c           	          | j         j        }dD ]=}|                      t           |d          |          d          t                     >d S )N)r  r  r  r   r  r#  r%  r'  r  r  )r   r   r  r"   rf  )r   r   r'   s      r   r2  zCoverage.test_rop  s`    ,&M 	N 	NDMM5'''#,,55e<<nMMMM	N 	Nr!   c                    | j         j        }| j         j        } |            5 }d|_        |                     t           |d                                                    d           |                     t           |d                                                    d           |                     t           |d                              d                    d           |                     t           |d	                              d
                    d           |                     t           |d	                              d                    d           |                     t           |d          j        d           |                     t           |d          j        dd           d d d            d S # 1 swxY w Y   d S )Nr  rh  r-  z9.99e-5re  ru  rw  z1.23457rf  r  z1.2345000000r  z0E+10rY  r  r  )	r   r   r  r+   r@  r;  	__round__rj  r2  )r   r   r  r  s       r   
test_roundzCoverage.test_round  s   ,&|0\^^ 
	JqAFS!:!:!<!<==tDDDS!3!3!=!=!?!?@@#FFFS!6!6!@!@!C!CDDiPPPS!2!2!<!<R!@!@AA>RRRS!2!2!<!<S!A!ABBGLLLi)BCHHHi)BAqIII
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	J 
	Js   FGG
G
c                 |    | j                                         }|                     t          |j        dg           d S )Nr!  )r   r.   rj  r  r   )r   r  s     r   test_create_decimalzCoverage.test_create_decimal  s8    L  ""*a&6>>>>>r!   c                 H   | j         j        }| j         j        } |            5 }d|_         |ddz            ddz  z  }|                     t          |          d           |                     |                                d           d d d            d S # 1 swxY w Y   d S )Nrd  i  i  r  iS  r  r  )r   r   r  r+   r@  r  r  r   r   r  r  r  s        r   rA  zCoverage.test_int  s    ,&|0\^^ 	1qAFd
##b$h.ASVVQ'''Q]]__a000		1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   A'BBBc                 V   | j         j        } |            }d|_        ddz   }|                    |          }|                     ||            |                    |          }|                     ||            |                    |d          }|                     ||            d S )Nr  i  i  r  )r   r.   r+   rq   r@  rs   ru   )r   r.   r  r  r  s        r   r  zCoverage.test_copy  s    ,&GIIdlOJJqMMQBMM!QBKK1QBr!   N)r   r_  r`  r  r  r  r  r  r  rZ  r  r2  r  r  rA  r  r   r!   r   r  r  *  s        7 7 7	 	 	  &O# O# O#b'5 '5 '5R/ / /(( ( (( ( (N N NJ J J"? ? ?1 1 1         r!   r  c                       e Zd ZeZdS )	CCoverageNr  r   r!   r   r  r  +  r  r!   r  c                   ,     e Zd ZeZ fdZ fdZ xZS )
PyCoveragec                     t                                                       t          j                    | _        t          j        d           d S r  r  r  s    r   r   zPyCoverage.setUp1  r  r!   c                 z    t          j        | j                   t                                                       d S r   r  r  s    r   r   zPyCoverage.tearDown6  r!  r!   r"  r$  s   @r   r
  r
  .  r%  r!   r
  c                       e Zd ZdZd ZdS )PyFunctionalityz!Extra functionality in decimal.pyc                     t           j        }t           j        }g d}|D ]3\  }}}|                     t	           ||          |          |           4d S )N)
)z.0er  z1e+0)z#.0er  z1.e+0)rH  r  r  )z#.0fr  1.)rP  1.1r  )z#gr  r  )rR  r  r  )z#.0gr  r  )rX  r  z100%)z#.0%r  z100.%)r  r   r  r@  r  )r   r   r  r  r  r   rN  s          r   test_py_alternate_formattingz,PyFunctionality.test_py_alternate_formatting=  sm    )~   * 	> 	>NCFVGGAJJ44f====	> 	>r!   N)r   r_  r`  ra  r  r   r!   r   r  r  :  s)        ++> > > > >r!   r  c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )
PyWhiteboxz White box testing for decimal.pyc                    t           j        }t           j        } |            5 }d|_         |d           |d          z  }|                     | |d                      |d           |d          z  }|                     | |d                      |d           |d          z  } |d           |d	          z  }|                     | |d
                      |d           |d	          z  } |ddz             |d	          z  }d|_         |d           |d          z  }d|_         |ddz             |d          z  }d d d            d S # 1 swxY w Y   d S )Nr  i   r  z
0.00390625z-0.6z0.0012885819256e7l   o z-0.0625re  152587890625e7rw  ic
  r  152587890625   r  iB  )r  r   r  r+   r@  r  s        r   test_py_exact_powerzPyWhitebox.test_py_exact_powerU  s   )~\^^ 	3qAF''&//1AQ 5 5666''&//1AQ 7 7888  GGFOO3A%%););;AQ///())WWY-?-??A4  GGI$6$66AAF''776??:AAF3776??2A)	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s   D1E!!E%(E%c                    	 t           j        }t           j        }t           j        }|                                }t          d t          t                    D                       |_         ||            |d           |d           |d          	 |d          d2	 fd	} |                                j	        j	                                        j
        j
                                        j        j                    |d            |dd            |d	d            |d
d            |dd            |dd            |dd            |dd            |dd            |d            |dd            |d            |d            |d            |dd            |dd            |d            |d            |d            |dd            |dd            |dd            |d            |dd            |dd            |d d            |d!d            |d"d            |d#            |d$d            |d%d            |d&            |d'            |d(d            |d)d            |d*d            |d+            |d,d            |d-d            |d.d            |d/            |d0            |d1           d S )3Nc              3      K   | ]}|d fV  	dS )r   Nr   r  s     r   r    z=PyWhitebox.test_py_immutability_operations.<locals>.<genexpr>w  s&      99!1v999999r!   z-25e55z33e+33Fc                    |rt          d| z   dz                                  j        j                                       j        j                                       j        j                                       j        j                                       j        j                                       j        j                   d S t          d| z   dz                                  j        j                                       j        j                                       j        j                   d S )Nzd1.z(d2)z())r<  r@  _sign_int_exp)	operationuseOtherb1b2r  r  r   s     r   checkSameDecz@PyWhitebox.test_py_immutability_operations.<locals>.checkSameDec  s1    3UY&/000  28444  "'222  "'222  28444  "'222  "'22222UY&-...  28444  "'222  "'22222r!   __abs__r  Tr  r  r  r  r  r  r  	__float__r$  r}  __int__	__trunc__r"  r  __neg____bool____pos__r&  r  r  r  r%  r#  r  r'  r  __str__r  r  rn  r  r$  r  r  r   r  r   r   r   r   r  )F)r  r   r<  r3   rn   r0   r9  r-   r@  r  r  r   )
r   r   r<  r3   r  r%  r#  r$  r  r  s
   `     @@@@r   test_py_immutability_operationsz*PyWhitebox.test_py_immutability_operationsp  s   ))\
!!99~a'899999
1WXWXWXWX	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	28,,,"'***"'***YY%%%\4(((Xt$$$Xt$$$Xt$$$Xt$$$Xt$$$Xt$$$[!!!^T***Z   Y[!!!Y%%%Y%%%YZ   YY%%%Z&&&]D)))Z   _d+++Z&&&Z&&&Z&&&Z&&&YY%%%]D)))Z   Z   Y%%%UD!!!UD!!![!!!Z&&&%t,,,^T***V_%%%]#####r!   c                     t           j        } |d          } ||          }|                     t          |          d           |                     t          |          t          |                     d S )Nrm  rn  )r  r   r@  r;  rT  rC  r  s       r   test_py_decimal_idzPyWhitebox.test_py_decimal_id  sg    )GBKKGAJJQ&&&BqEE2a55)))))r!   c                    t           j        }t           j        } |            5 } |d                              dt                    }|                     |                                           d d d            d S # 1 swxY w Y   d S )Nr}  r  )r  r   r  _rescaler   r#   r   r  s        r   test_py_rescalezPyWhitebox.test_py_rescale  s    )~\^^ 	(q''844AOOAHHJJ'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   AA<<B B c                 ~    t           j        }|                     t           |d          j        dt
                     d S )Nz3.1234r   )r  r   rj  r  _roundr   rg  s     r   test_py__roundzPyWhitebox.test_py__round  s6    )*ggh&7&7&>8LLLLLr!   N)	r   r_  r`  ra  r  r.  r0  r3  r6  r   r!   r   r  r  R  sn        **3 3 36M$ M$ M$^* * *( ( (M M M M Mr!   r  c                   T    e Zd ZdZed             Zed             Zed             ZdS )CFunctionalityzExtra functionality in _decimalc                    t           j        }t           j        }t           j        }t           j        }d } ||          }|                     |j        d           |                     |j        d           |                     |j        d            || |            ||          }|                     |j        d           |                     |j        d           |                     |j        d            || |            ||          }|                     |j        d           |                     |j        d	           |                     |j        d
            || |           | 	                    t          |d           | 	                    t          |d           | 	                    t          |d           d S )Nc                     |                      |j        d           t          | |dg            t          | |dg            d S )Nr  r-   rR  )r@  ra   r(   )r   r&   s     r   assert_restz7CFunctionality.test_c_ieee_context.<locals>.assert_rest  sH    W]A...4'26664'266666r!   r  `   ir  rK  rL  "   i   ir  ru  i   )r   IEEEContext	DECIMAL32	DECIMAL64
DECIMAL128r@  r+   r]  rX  rj  r  r  )r   r>  r?  r@  rA  r;  r  s          r   test_c_ieee_contextz"CFunctionality.test_c_ieee_context  s    mK	K	\
	7 	7 	7
 K	""###$$$%%%D!K	""$$$%%%&&&D!K
##$$$&&&'''D! 	-e<<<*k2666*k488888r!   c                     t           j        } |t           j        t           j                  }|                     |j        t           j                   |                     |j        t           j                   d S )N)rR  r-   )r   r.   r9   
DecRoundedr@  _flags_trapsr  s      r   test_c_contextzCFunctionality.test_c_context  s[    )G!,al;;;1<0001<00000r!   c                    t           j        t           j        t           j        t           j        t           j        t           j        t           j        t           j        t           j	        t           j
        t           j        t           j        t           j        t           j        t           j        f}|                     t           j        d           |                     t           j        d           |                     t           j        d           |                     t           j        d           t+          |          D ]\  }}|                     |d|z             |                     t           j        t           j        t           j        z  t           j        z  t           j        z  t           j        z  t           j	        z  t           j
        z             |                     t           j        t           j        t           j        z             |                     t           j        t           j        t           j        z  t           j        z             d S )Nrs  r     i   r  )r   r9   DecConversionSyntaxDecDivisionByZeroDecDivisionImpossibleDecDivisionUndefinedDecFpuError
DecInexactDecInvalidContextDecInvalidOperationDecMallocErrorDecFloatOperationDecOverflowrD  DecSubnormalDecUnderflowr@  r?  r@  rA  IEEE_CONTEXT_MAX_BITSr5  DecIEEEInvalidOperation	DecErrorsDecTraps)r   condrK  r   s       r   test_constantszCFunctionality.test_constants  s    L!/1D#Q%;M1<)<!1#3NAN
 	b)))b)))s+++0#666 dOO 	& 	&DAqQ1%%%%2.01/0 ' ,	-
 ./ )*	+ 	+ 	+ 	2,-	. 	. 	. 	Q]21>A	C 	C 	C 	C 	Cr!   N)r   r_  r`  ra  requires_extra_functionalityrB  rG  r\  r   r!   r   r8  r8    sr        ))!!9 !9 "!!9F "1 1 "!1 "#C #C "!#C #C #Cr!   r8  c                      e Zd ZdZd Zd Zd Zd Zd Zd Z	e
d             Zd	 Ze
d
             Zd Zd Zd Zd Zd Ze
d             Ze
d             Zd Zd Zd Zd Zd Z ej        ej                            d          d           ej        ed           ej         e dd          d          d                                     Z!d Z"dS ) 	CWhiteboxzWhitebox testing for _decimalc                 |   t           j        }t           j        }ddz  }ddz  } |            5 }d|_        t	          d          D ]^}t          j        ||          }t          j        dd          }||z  }	 ||           ||          z  }
|                     |	|
           _	 d d d            d S # 1 swxY w Y   d S )Nr  #   $   i@B rw  r  i  )r   r   r  r+   rx  r.  r  r@  )r   r   r  r#  r$  r  rK  r  r\  r  r  s              r   test_bignumzCWhitebox.test_bignum/  s    )~VV\^^ 	'qAF1XX ' '$R,,$T400FGAJJ''!**,  A&&&&'	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	's   A6B11B58B5c                 T    |                      t          t          j        dd           d S )Nr*   r  )rj  r2  r   r   r   s    r   test_invalid_constructionz#CWhitebox.test_invalid_construction@  s$    )QY599999r!   c                     t           j        }t           j        }t           j        }t           j        } | |                      5  |                     ||d           d d d            d S # 1 swxY w Y   d S )N1e9999999999999999999)r   r   r   r.   r  rj  )r   r   r   r.   r  s        r   test_c_input_restrictionz"CWhitebox.test_c_input_restrictionC  s    )-)~\''))$$ 	7 	7.57 7 7	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   A))A-0A-c                    t           j        }t           j        }|                                }d|_        d|_        d|_        t          |_        d|_	        d|_
        t          t                    D ]}d|j        |<   d|j        |<   d|j        |<   d|j        |<   |                                }d}|                     ||           d S )Nr   r:  r   r  TaQ  Context(prec=425000000, rounding=ROUND_HALF_DOWN, Emin=-425000000, Emax=425000000, capitals=0, clamp=1, flags=[Clamped, InvalidOperation, DivisionByZero, Inexact, FloatOperation, Overflow, Rounded, Subnormal, Underflow], traps=[Clamped, InvalidOperation, DivisionByZero, Inexact, FloatOperation, Overflow, Rounded, Subnormal, Underflow]))r   r<  rt  rn   r+   r]  rX  r   r,   r  ra   r9  rR  r-   r  r@  )r   r<  rt  r  r,  r   r   s          r   test_c_context_reprzCWhitebox.test_c_context_reprN  s     ))!!$

!!$ 	  	 CAGCLAGCLL"&"&JJLLO 	Ar!   c           	         t           j        }t           j        }t           j        }t           j        }t           j        }t           j        }t           j        }t           j        dk    } |            }	| 	                    t          |	j        j        dd           | 	                    t          |	j        j        dd           | 	                    t          |	j        j        |           | 	                    t          |	j        j        |           | 	                    t           t"          |	ddg           | 	                    t           t"          |	ddg           | 	                    t          t"          |	dddi           | 	                    t          t"          |	dddi           |	j                                        }
|
|= d	|
d
<   | 	                    t          t"          |	d|
           | 	                    t          t"          |	d|
           |rdnd}|rdnd}dD ]%}| 	                    t          t"          |	||           &| 	                    t          t"          |	d|            | 	                    t          ||           | 	                    t          ||           | 	                    t          ||            | 	                    t&          ||dz              | 	                    t&          ||dz              | 	                    t&          || dz
             | 	                    t&          ||dz              | 	                    t&          ||dz              dD ]}| 	                    t&          t"          |	||dz              | 	                    t&          t"          |	|| dz
             t(          j        dk    rJ| 	                    t          t"          |	||           | 	                    t          t"          |	|| dz
             t           j        dk    r| 	                    t&          t-          |	d          |dz              | 	                    t&          t-          |	d          |dz              | 	                    t&          t-          |	d          | dz
             t           j        dk    r| 	                    t          t-          |	d          d           | 	                    t          t-          |	d          d           | 	                    t          t-          |	d          d           | 	                    t          t-          |	d          d           | 	                    t          t-          |	d          d           | 	                    t          t-          |	d          d           dD ]}| 	                    t          t"          |	|d           | 	                    t          t"          |	|d           | 	                    t           t"          |	|g d            |rF| 	                    t          t"          |	|d!           | 	                    t          t"          |	|d"           | 	                    t           t.          d#t1                                 | 	                    t           t.          d$t1                                  |            }| 	                    t           |d%            ||           d S )&Nr   i!  r   rR  r  r-   r  r  ipr  r  r  l     NZoi ʚ;r  rX  r:  r@  r?  r  rB  rA  )r+   rX  r]  r  ra   win32r   r   r   i?ru  i9r  r                 zwith localcontext("xyz"): passz-with localcontext(context=getcontext()): passr  )r   r.   r   r   rt  r  r  r3   rU  rj  r  rR  __setitem__r-   r  __delitem__r2  r/  rn   r  r  platformr"   execr  )r   r.   r   r   rt  r  r  r3   HAVE_CONFIG_64r  r   int_maxgt_max_emaxr'   saved_contexts                  r   test_c_context_errorszCWhitebox.test_c_context_errorsk  si   )-:)~\
\
*y0GII 	(AG$7a@@@(AG$7a@@@*ag&98DDD*ag&9;KLLL)Wa3%@@@)Wa#???(GQ!A???(GQ!A??? GLLNNn%(GQ;;;(GQ;;; ,8'' .9ffE % 	I 	IDj'1dKHHHH*gq&;,GGG 	*gK@@@*gK@@@*g[LAAA 	-wqyAAA-wqyAAA-xzBBB-	BBB-719EEE B 	L 	LDmWawqyIIImWaxzJJJ|w&&!!*gq$HHH!!*gq$
KKK :""mWQ8I-J-J%ai) ) )mWQ8I-J-J%ai) ) )mWQ8I-J-J&hqj* * * :""j'!5F*G*GKKKj'!5F*G*G(* * *j'!5F*G*GLLLj'!5F*G*G(* * *j'!5F*G*G)+ + +j'!5F*G*GKKK * 	I 	IDj'1dB???j'1dA>>>i!T777CCC I!!*gq$FFF!!*gq$HHH 	)T+K ((	$ 	$ 	$)TI ((	$ 	$ 	$
 #
)Z777
=!!!!!r!   c                    |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j	        t          j	                   |                      t          j
        t          j
                   d S r   )r  r   r   r  r   r   r   r   r   r/   r   r   s    r   test_rounding_strings_internedz(CWhitebox.test_rounding_strings_interned  s    aj!*---alAL111aoq777amQ]333aoq777a'):;;;a'):;;;alAL11111r!   c           	      x   t           j        }t           j        }t           j        }t           j        }t           j        }t           j        }t           j        dk    } |            }|rdnd}	|                     t          t          |d|	dz              |                     t          t          |d|	 dz
             t          j        dk    rJ|                     t          t          |d|	           |                     t          t          |d|	 dz
             dD ]}
|                     t          t          ||
|	dz              |                     t          t          ||
|	 dz
             t          j        dk    rJ|                     t          t          ||
|	           |                     t          t          ||
|	 dz
             |                     t          t          |dd	           |                     t          t          |dd           |                     t          t          |dg d
           |rF|                     t          t          |dd           |                     t          t          |dd           dD ]H}
|                     t          t          ||
d           |                     t          t          ||
d           Id S )Nr   r  r  _allcrr  r  rl  )rE  rF  ru  r  rm  rn  r  r  )r   r.   r   r   r  r  r3   rU  rj  r  r/  r  rq  r  r2  )r   r.   r   r   r  r  r3   rs  r  rt  r'   s              r   test_c_context_errors_extraz%CWhitebox.test_c_context_errors_extra  sz   )-:~\
\
*y0GII ,8'' 	-!XwqyIII-!XxzJJJ<7""j'1hHHHj'1h
KKK ) 	K 	KDmWawqyIIImWaxzJJJ|w&&!!)WawGGG!!)WaxzJJJ 	*gq(B???*gq(A>>>)Wa777CCC 	Ij'1hFFFj'1hHHH ) 	@ 	@Di!T6BBBi!T3????	@ 	@r!   c                 N   t           j        }t           j        }t           j        }t           j        }t           j        }t           j        }|                                }d|_        t          |_
        d|_        d|_        d|_        d|_        |                     |j        d           |                     |j
        t                     |                     |j        d           |                     |j        d           |                     |j        d           |                     |j        d           |                     |                                d           |                     |                                d           t           j        dk    r|                    d	           |                    d	           |                    d
           |                     |j        d	           |                     |j        d	           |                     |j        d
           d S d S )Nr=  i  iHr  r   i'i  r   ri  rj  )r   r<  r   r   r   r   r   rn   r+   r   r,   r]  rX  r  ra   r@  EtinyEtoprU  r   r   r   )r   r<  r   r   r   r   r   r  s           r   test_c_valid_contextzCWhitebox.test_c_valid_context  s   ))K	))K	!! "

$$$]333'''&&&Q'''!$$$E***4((( :""i(((i(((j)))QVY///QVY///QVZ00000 #"r!   c                     t           j        }|                                }|                     |j        d           d|_        |                     |j        d           d S )Nr  r   )r   r<  rn   r@  r{  )r   r<  r  s      r   test_c_valid_context_extraz$CWhitebox.test_c_valid_context_extra,  sX    )!!1%%%1%%%%%r!   c           	      <   t           j        }t           j        }t           j        }t           j        }t           j        }t           j        dk    rdnd} |            5 }d|j        |<   |                     | |d          j	        | dz
             |                     | |d          j	        |           |                     | |d          j	        t          |dz                        |                     t           j         |d          j	        t          |dz
                        |                     t           |d          j	        | dz
             |                     t           |d          j	        |dz              d d d            d S # 1 swxY w Y   d S )	Nr   r  r  TrY  r  r  r  )r   r   r   r  r   rq  rU  r-   rj  r   r  r  )r   r   r   r  r   rq  rt  r  s           r   test_c_roundzCWhitebox.test_c_round5  s   )-~:K	Z)33''\^^ 	)q(,AG$%.0I&hqj* * *.0I%' ' '.0F!(1*oo/ / /a0''#,,2H"9Q;///1 1 1mWWV__-F&hqj* * *mWWV__-F%ai) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   D)FFFc                    t           j        }t           j        dk    }|                     t           |d          j        dg d           |                     t           |d          j        dd           |                     t           |d          j        g            |                     t           |d          j        d           |rdnd}|                     t           |d          j        d	|z             d S )
Nr   r  z=10.10r*   z<>=10.10r  r  ru  z=%d.1)r   r   rU  rj  r2  r  r  )r   r   rs  maxsizes       r   test_c_formatzCWhitebox.test_c_formatM  s    )*y0)WWQZZ%:Hb!LLL)WWQZZ%:HaHHH)WWQZZ%:B???*ggajj&;ZHHH+8''*ggl&;&;&F!G+	- 	- 	- 	- 	-r!   c                 b   t           j        }t           j        }t           j        } |d          }|                     |                                d           |                     t          |j        d           |                     t          |j        dd           |                     t          |j        d           |                     |                                d           |                     t          |j        d           |                     t          |j        dd           |                     t          |j        d           |                     |	                                d           |                     t          |j	        d           |                     t          |j	        dd           |                     t          |j	        d            |            5 } |d                              t                    }|                     | |d                      |d          	                    t                    }|                     | |d                     d|j        |<   |                     | |d          j	        t                     d d d            d S # 1 swxY w Y   d S )Nr  r-  r  z99999999999999999999999999.9100000000000000000000000000Tz999.9)r   r   r   r  r@  r  rj  r2  r   r   r   r-   )r   r   r   r  r  r  s         r   test_c_integralzCWhitebox.test_c_integral[  s   ))~GBKK"---)Q]D999)Q]B<<<)Q]B777,,..333)Q%8$???)Q%8"cBBB)Q%8"===,,..333)Q%8$???)Q%8"cBBB)Q%8"===\^^ 	Uq677II(SSAQ(E F FGGG677II(SSAQ(E F FGGG#AGGgwww'7'7'I8TTT	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	Us   B9J$$J(+J(c           
         t           j        }t           j        }t           j        }t           j        }t           j        }|                      |d                                          d           |                     t          t           |d          dd           |                     t           |d          j        dd           |                     t           |d          j        d	dd           |                     t           |d
          j         |d          g            |                     t           |d
          j         |d           |                       |                     t           |d
          j         |d          d           |                     t           |d
          j         |d          t          d            |            5 }|                                 |                     t          |j         |d          dd           |                     t          |j        d           |                     t          |j        d           |                     t          |j        dddd           |                     t          |j        dd	dd           |                     t)          |                     |d                              d           |                     |                                d           d|j        |<   |                     | |d          j        d           |                     ||j        dd           |                     |j        |                    |                                 d|j        |<   |                     | |d          j        d           |                     ||j        dd           |                     |j        |                    d|j        |<   d|_        |                     |t           |d          dd           d d d            d S # 1 swxY w Y   d S )Nz9.99e10z99.9E+9r  r  rJ  r*   r  r  r  ru  z	1e-100000r  r  r  r  200Tr   i  )r   r   r   r   r  r  r@  r   rj  r2  r  rg   r   r  r   r  ru   rp  r{   r.  r;  ro  r-   r  r#   rR  r/  r+   )r   r   r   r   r  r  r  s          r   test_c_funcszCWhitebox.test_c_funcsz  sC   )-)\
~++99;;YGGG)S''!**a===)WWQZZ%<c3GGG)WWQZZ%<acJJJGL!!*GGK,@,@"	
 	
 	
 	GL!!*GGK,@,@**,,	
 	
 	
 	GL!!*GGK,@,@"	
 	
 	
 	GL!!*GGK,@,@(D	
 	
 	

 \^^ 	LqMMOOO iggajj#sKKKic:::i===i1acBBBiAsCHHHSWWS\\!:!:;;UCCCQWWYY+++&*AGN#nggajj.CQGGGnah1===OOAG$45666MMOOO(,AG$%.

0EqIII.!Q???OOAGN3444(,AG$%AF.WWT]]AsKKK5	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   IP<<Q Q c                 P   t           j        }t           j        } |d          }dD ]M}t          ||          }|                     t
          |d           |                     t
          |dd            NdD ]M}t          ||          }|                     t
          |d           |                     t
          |dd            N|                     t
          |j        d g            |                     t
          |j        i g            |                     t
          |j        g g            |                     t
          |j        d g            |                     t
          |j        i g            |                     t
          |j        g g            |                     t
          |j        d g            |                     t
          |j        i g            |                     t
          |j        g g            |                     t
          |j	        ddd           |                     t
          |j	        dddd            |                     t
          |j
        dg d            |                     t
          |j
        dg d 	           |                     t
          |j
        dg g             |            }|                     t
          |j        ddd
           |                     t
          |j        ddd 
           |                     t
          |j        ddd 
           d S )N10001111111)rZ  r   r   r  r   r  ry   r   r   r   rg   r   r   r  r  )r$  ri   rc   r   r  r   r  r   r   r  r  r  r  r  r  rV  )mod)r   r   r.   r"   rj  r2  r  r   r   r  r  r  )r   r   r.   r  r'   funcr  s          r   test_va_args_exceptionsz!CWhitebox.test_va_args_exceptions  s   ))GM""K 	B 	BD 1d##Dis;;;isDAAAAD 	B 	BD 1d##Dis;;;isDAAAA)Q]T2NNN)Q]RLLL)Q]B;;;)Q%84QSTTT)Q%82rRRR)Q%8"bAAA)Q%84QSTTT)Q%82rRRR)Q%8"bAAA)QUAq#>>>)QUAq#tDDD)QZBEEE)QZBFFF)QZB;;;GII)QWa<<<)QWa$???)QWc1$?????r!   c                 ^   |                      t          j        j        t          j        t          j        z  t          j        z  t          j        z  t          j        z             |                      t          j	        j        t          j        t          j        z  t          j        z             d S r   )
r@  r   r  rF  rX  rK  rT  rV  r9   r<  r   s    r   test_c_context_templatesz"CWhitebox.test_c_context_templates  s    N!%a&99!-GN<(	
 	
 	

 	#%a&99!-G	
 	
 	
 	
 	
r!   c                     t           j        }t           j        }t           j        }t           j        }t           j        }t           j        }t           j        }t           j        }t           j	        }	t           j
        }
t           j        }t           j        }t           j        }t           j        } fd}|                                }                     ||j        v            |                                 |j                                        D ]}d|j        |<   |j                                        D ]}                     |           |                                 |j                                        D ]\  }}                     |                                |j                            |                                          |j                            d          d                                 |j                            dd          d                                t8          |j        j        ddd                                t;          |j                  t;          |j                             t=          j        |j                  }t=          j        |j                  }|j                                         }|!                                 ||_"                             |j        |                    |                                 ||_#                             |j        |                    |!                                 |j                                        }d||<   ||_         |||j                   |                                 |j                                        }d||<   ||_         |||j                   |t           j        |	t           j$        |
t           j%        |t           j&        |t           j'        |t           j(        |t           j)        |t           j*        |t           j        i	}t           j+        t           j,        t           j-        t           j.        t           j        t           j/        t           j0        g}t;          tb          t                              }te          |          D ]}te          |          D ] }tf          D ]}ti          j5        tb          t                    |          }ti          j5        tb          t                    |          }ti          j6        dd          }ti          j6        dd	          }ti          j6        d	d          }ti          j6        d	d
          } ti          j6        d	d
          }!ti          j6        d	d
          }" ||||||!| to          |          to          |                    }                     |j8        |                                |j9        |                                |j:        |                                |j;        |                                |j<        |!                                |j=        |            d	}#|D ]}$|#||$         z  }#                     |j"        |#           d	}#|D ]}$|#||$         z  }#                     |j#        |#           |D ]7}%|%|_"                             |j"        |z              |||j                   8|D ]7}%|%|_#                             |j#        |z              |||j                   8d S )Nc                     |D ]?}|| k    r                     ||                    $                    ||                    @d S r   )r#   r%  )rz  signal_dictr,  r   s      r   assertIsExclusivelySetz<CWhitebox.test_c_signal_dict.<locals>.assertIsExclusivelySet  s[    " 7 7&==OOK$45555$$[%56666	7 7r!   Tr  r  r	  r  r  ir   r  r  )>r   r.   r<  r   rt  r   r   r   r   r   r   r   r9   rQ  rX  rn   r#   r-   r  r  valuesr  r%  rR  r  r  r@  rj  r2  r  r  	getsizeofr  r/  rE  rF  rD  rO  rU  rV  rT  rK  rS  rL  rM  rN  rP  rR  rJ  r9  rx  r  r.  sampler  rV  r+   r,   rX  r]  r  ra   )&r   r.   r<  r   rt  r   r   r   r   r   r   r   r9   rQ  rX  r  r  ri  r   r   r   
IntSignalsIntCondlimr  r   r  rR  r-   r+   rt  rs  ra   r  crr   r  r[  s&   `                                     r   test_c_signal_dictzCWhitebox.test_c_signal_dict  si    ))-)):K	K	)))\
3"#";	7 	7 	7 	7 	7 !! 	AG+,,,	 	 	AAGAJJ!! 	 	AOOA	GMMOO 	  	 DAqQX..///agkk#&&---S#..444)QW[#sC@@@QWs17||444M!'""M!'""G 	
()))	& 01222 	
GLLNN .~qw777	GLLNN)y!'222 1<
1<
1<
Q^
Q^
AM
!-
!-
A5


 
!1#91=

q4a6F


 .#$$s 	2 	2A3ZZ 2 2* 2 2E"M.*;Q??E"M.*;Q??E!+Au55D!+FA66D!+Au55D",Q22E!+Aq11D)!Q//BTE4)-U$u++&*5kk3 3 3A $$QVT222$$QZ777$$QVT222$$QVT222$$QZ666$$QWe444A" + +Z]*$$QXq111A" + +Z]*$$QXq1111922>  	> 	>DAHOOAH%<<===""#3QW==== 	> 	>DAHOOAH%<<===""#3QW====	> 	>r!   c                    t           j        	 ddlm} n%# t          $ r |                     d           Y nw xY wd }dfd	}d |g d          dd	}d
 |g d          dd	}d |g d          dd	}|dk    r|                     t          |d|d           |                     t          |d|d           |                     t          |d|d           d S )Nr   r  r  c                 @    d                     d | D                       S )Nr   c                 ,    g | ]}t          |          S r   r  r  s     r   r'  zJCWhitebox.test_invalid_override.<locals>.make_grouping.<locals>.<listcomp>|  r  r!   )r  )r  s    r   r  z6CWhitebox.test_invalid_override.<locals>.make_grouping{  s#    7700C000111r!   ry  c                 B     |                                ||          S r   )r  )r  r  r  r   s      r   r  z0CWhitebox.test_invalid_override.<locals>.get_fmt~  s!    71::((h777r!   rg  )   r  r   r  xxxxxr  r  yyyyy   r  rP  r  )r   r   r  r  r  r  rj  r  )r   r  r  r  invalid_groupinginvalid_dotinvalid_sepr   s          @r   test_invalid_overridezCWhitebox.test_invalid_overrides  sc   )	;''''''' 	; 	; 	;MM9:::::	;	2 	2 	2	8 	8 	8 	8 	8 	8 "&}}}55!
 
 &&yyy11!
 
 "&yyy11%
 
 s??j'5.5 5 5 	*guk3GGG*guk3GGGGGs    88c                    t           j        }t           j        }t           j        } |            5 }d|j        |<   dt
          j        z  }|                     |||           dt
          j         dz
  z  }|                     |||           dt
          j        z  }|                     |||           dt
          j         dz
  z  }|                     |||           d d d            d S # 1 swxY w Y   d S )NTz0e%dr  z1e%d)r   r   r  r   r-   r  r  rj  r  s         r   test_exact_conversionzCWhitebox.test_exact_conversion  s9   )~-\^^ 	<q(,AG$% $A.;;;3;,q.)A.;;; $A.;;; 3;,q.)A.;;;#	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   B+C''C+.C+c                    t           j        }t           j        }t           j        }t           j        }t           j        } |            5 }d|_        d|j        |<   d|j        |<   d|j        |<   ddt          j	        f}| 
                    t          |                    |                    d           |                     |||           ddt          j	        f}|                     ||j        |           |                     |||           ddt          j	         dz
  f}| 
                    t          |                    |                    d           |                     |||           ddt          j	         dz
  f}|                     ||j        |           |                     |||           ddt          j	        dz   f}|                     t          |j        |           |                     t          ||           ddt          j	         dz
  f}|                     t          |j        |           |                     t          ||           d	}| 
                    t           ||                    d
           d}| 
                    t           ||                    d
           d}| 
                    t           ||                    d           d d d            d S # 1 swxY w Y   d S )Nr*   Tr  r   z
-0E+999999)r   r  r  z-0E-1000007r  r  r]  )r  r  r  )r  r  r  z-sNaN1)r   r   r  r   r   r   r+   r-   r  r  r@  r;  r   rj  r  )r   r   r  r   r   r   r  r  s           r   test_from_tuplezCWhitebox.test_from_tuple  s   )~-:K	\^^ (	8qAF(,AG$% $AGH!%AGI B$AS!1!1!!4!455|DDD.;;;Is{+Ah(8!<<<.;;; BQ'AS!1!1!!4!455}EEE.;;;I|A~.Ai)91===.;;; BA&AmQ-=qAAAmWa888BQ'AmQ-=qAAAmWa888 AS__g666AS__g666 AS__h777Q(	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8 (	8s   JK''K+.K+c                    t           j        }t           j        dk    }|                      |d                                          d           |r[ |ddz                                            } |ddz                                            }|                     ||dz              d S  |ddz                                            } |ddz                                            }|                     ||d	z              d S )
Nr   r   r  r  i  r        r  )r   r   rU  rP  
__sizeof__r@  )r   r   rs  r  r  s        r   test_sizeofzCWhitebox.test_sizeof  s   )*y0771::0022A666 	%U$$//11AU$$//11AQ!$$$$$T
##..00AT
##..00AQ!$$$$$r!   c                 V   t           j        } G d dt                    } G d dt                    } G d dt                     G fddt                    }|||fD ]G}|                     |                     |d	                    |                    d	                     Hd S )
Nc                       e Zd Zd Zd ZdS )<CWhitebox.test_internal_use_of_overridden_methods.<locals>.Xc                     dS Nr  r   r   s    r   r  zMCWhitebox.test_internal_use_of_overridden_methods.<locals>.X.as_integer_ratio  s    qr!   c                     | S r   r   r   s    r   r&  zDCWhitebox.test_internal_use_of_overridden_methods.<locals>.X.__abs__      r!   Nr   r_  r`  r  r&  r   r!   r   Xr    s2              r!   r  c                       e Zd Zd ZdS )<CWhitebox.test_internal_use_of_overridden_methods.<locals>.Yc                     dgdz  S Nr  r  r   r   s    r   r&  zDCWhitebox.test_internal_use_of_overridden_methods.<locals>.Y.__abs__      s3wr!   N)r   r_  r`  r&  r   r!   r   Yr    #            r!   r  c                       e Zd Zd ZdS )<CWhitebox.test_internal_use_of_overridden_methods.<locals>.Ic                     dgdz  S r  r   r   s    r   
bit_lengthzGCWhitebox.test_internal_use_of_overridden_methods.<locals>.I.bit_length  r  r!   N)r   r_  r`  r  r   r!   r   Ir    r  r!   r  c                        e Zd Z fdZd ZdS )<CWhitebox.test_internal_use_of_overridden_methods.<locals>.Zc                 0     d           d          fS r  r   )r   r  s    r   r  zMCWhitebox.test_internal_use_of_overridden_methods.<locals>.Z.as_integer_ratio  s    !aadd|#r!   c                     | S r   r   r   s    r   r&  zDCWhitebox.test_internal_use_of_overridden_methods.<locals>.Z.__abs__  r  r!   Nr  )r  s   r   Zr    s=        $ $ $ $ $    r!   r  gfffffFY@)r   r   r  r  r@  r  )r   r   r  r  r  r%   r  s         @r   'test_internal_use_of_overridden_methodsz1CWhitebox.test_internal_use_of_overridden_methods  s#   )	 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	 a7 	8 	8CW//E

;;$//668 8 8 8	8 	8r!   aixzEAIX: default ulimit: test is flaky because of extreme over-allocationzTest is unstable on EmscriptenT)addressmemoryzVASAN/MSAN sanitizer defaults to crashing instead of returning NULL for malloc failure.c                 V   g d}t           j        }t           j        }t           j        } |t           j        t           j        t           j                  } ||          5  |                      |d                                          d           |                      |d          	                                d           |                      |d          
                                d           |                      |d          
                                d           |                      |ddz            
                                d           |                      |d	                                          d
           |                      |d                                          d           |                      |d                                           |d                     |                     t           |d          d          d           |                      |d          dz  d           |                      |d          dz  d           |                      |d          dz   |d                     d d d            d S # 1 swxY w Y   d S )N)	ry   r   r   rc   r   r   r   r  r  )r+   rX  r]  r   r  r  r  r     l     9V    r  40E9z2.0E+5r  )r  r  i  ru  z0.0025)r   r   r.   r  rU  rp  r   r@  rZ  r  r   r  r   r.  )r   MaxContextSkipr   r.   r  
maxcontexts         r   test_maxcontext_exact_arithz%CWhitebox.test_maxcontext_exact_arith  s   < < < ))~ W!*1:AJOOO
\*%% 	D 	DWWQZZ^^--q111WWQZZ]]__a000WWQZZ--//333WWU^^1133Q777WWRW--3355s;;;WWV__1133R888WWQZZ__..222WWV__1133WWX5F5FGGGVGGBKK33V<<<WWR[[A-q111WWQZZ!^Q///WWS\\R/1B1BCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds    H1JJ"%J"c                    t          t                                          j                  } |            }d}|                     t
          |          5  t          |           d d d            n# 1 swxY w Y   |                     t
          |          5  t          |           d d d            n# 1 swxY w Y   |                     t
          |          5  t          |           d d d            n# 1 swxY w Y   |                     t
          |          5  d|t          j	        <   d d d            n# 1 swxY w Y   |                     t
          |          5  |t          j	                  d d d            n# 1 swxY w Y   |                     t
          |          5  |t                                          j        k     d d d            n# 1 swxY w Y   |                     t
          |          5  t                                          j        |k     d d d            n# 1 swxY w Y   |                     t
          |          5  |
                                 d d d            d S # 1 swxY w Y   d S )Nzinvalid signal dictT)r:  r   r.   rR  assertRaisesRegexr  r  iterr?  r   rn   )r   
SignalDictsderr_msgs       r   test_c_signaldict_segfaultz$CWhitebox.test_c_signaldict_segfault5  s   !))+++,,
Z\\'##J88 	 	GGG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ##J88 	 	HHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ##J88 	 	HHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ##J88 	* 	*%)Bq!"	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* ##J88 	# 	#q!""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# ##J88 	$ 	$!))++###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ ##J88 	$ 	$IIKK##	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ ##J88 	 	GGIII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A//A36A3B11B58B5C33C7:C7D55D9<D9E::E>E> #GGG5#H$$H(+H(
I,,I03I0N)#r   r_  r`  ra  rc  re  rh  rj  rw  ry  r]  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   skipIfr  rq  r  r   r   r  r  r   r!   r   r_  r_  +  sO       ''' ' '": : :	7 	7 	7  :c" c" c"J	2 	2 	2 "(@ (@ "!(@T$1 $1 $1L "& & "!&) ) )0- - -U U U>9L 9L 9Lv*@ *@ *@X "	
 	
 "!	
 "C> C> "!C>J#H #H #HJ< < <0/8 /8 /8b% % %8 8 8: X_S\,,U33\^ ^X_]$DEEX___T$???EF F D  DF F FE^ ^ DF    r!   r_  c                       e Zd ZdZd Zd ZdS )SignatureTestzFunction signaturesc                    t          t                    D ]V}|                    d          rt          t          |          }t          t          |          }|dk    s|dk    st          j        |          rt          j        |          }t          j        |          }t          |j	        
                                          }d |j	        
                                D             }|                     ||d|z             d |j	                                        D             }d |j	                                        D             }	|d	k    r|                     ||	d
|z             Xd S )NrL  r   r.   c                 <    g | ]}|                     d           |S )rL  r  r  s     r   r'  z5SignatureTest.test_inspect_module.<locals>.<listcomp>e  s8     . . .<<,,.1 . . .r!   parameter name mismatch in %smsgc                     g | ]	}|j         
S r   kindr  s     r   r'  z5SignatureTest.test_inspect_module.<locals>.<listcomp>k  s    DDDQ!&DDDr!   c                 ^    g | ]*}|d                               d          |d         j        +S )r   rL  r  )r  r  r  s     r   r'  z5SignatureTest.test_inspect_module.<locals>.<listcomp>l  sB     0 0 0A$//#..0!A$) 0 0 0r!   r3   parameter kind mismatch in %s)r  r  r  r"   r   inspect
isfunction	signaturerV  
parametersr  r@  r  r  )
r   r'   p_funcc_funcp_sigc_sigc_namesp_namesc_kindp_kinds
             r   test_inspect_modulez!SignatureTest.test_inspect_moduleX  s   FF 	S 	SDs## Q%%FQ%%F	!!TY%6%6"6** &7)&11)&11 u/446677. .e&6&;&;&=&= . . .   '%Dv%M ! O O O ED%*:*A*A*C*CDDD0 0U-=-C-C-E-E 0 0 0 <''$$VV)H6)Q % S S S1	S 	Sr!   c                     t           j        j        t           j        j        t          t                              d          t                              d          t                              d          t                              d          t                              d          t                              d          t                              d          t                              d          t                              d          t                              d          ddt          j        t                                          dt          t                              d          t                              d          t                              d          t                              d          t                              d          t                              d          t                              d          ddt          j        t                                          difdd  fd} |d	            |d
           d S )Nr  r  r  )r  rj  r  r  r	  r  r\  r  rZ  r
  numr   r,   r&   )r  rj  r  r\  r  rZ  r
  r  r   r,   r&   c                    g }i }|j                                         D ]d\  }}|dk    r|j        k    r"|                    |          |                    9|j        k    r|          |         ||<   Vt	          d          ||fS )Nr   zunexpected parameter kind)r  r  r  r8  r   )	moduler,  r  kwargsnameparamPOSPOS_KWDpdicts	         r   mkargsz0SignatureTest.test_inspect_types.<locals>.mkargs  s    DF"~3355 B Be6>>8:$$KKfd 34444Z7**#(=#6F4LL$%@AAA<r!   c                 6    | dk    rdS | dk    rdS | dk    rdS | S )zwThe C Context docstrings use 'x' in order to prevent confusion
               with the article 'a' in the descriptions.r  r  r  r\  r	  r  r   )r   s    r   trz,SignatureTest.test_inspect_types.<locals>.tr  s0     CxxCxxCxxHr!   c           
      n   t          t          |           }t          t          |           }t          |          D ]x}|                    d          rt          ||          }t          ||          }t          j        |          r*t          j        |          }t          j        |          }t          |j	        
                                          }fd|j	        
                                D             }	                    |	|d|z             d |j	                                        D             }
d |j	                                        D             }                    |
d                                        |d                    | dk    r,                    |d	d          |
d	d          d
|z             n5                    t          |          t          |
          d
|z              t          |          \  }}	  t           |d          |          |i | n&# t          $ r t!          d|d|d|          w xY w t          |          \  }}	  t           |d          |          |i | R# t          $ r t!          d|d|d|          w xY wzd S )NrL  c                 &    g | ]} |          S r   r   )r   r  r  s     r   r'  zBSignatureTest.test_inspect_types.<locals>.doit.<locals>.<listcomp>  s!    FFFrr!uuFFFr!   r  r  c                     g | ]	}|j         
S r   r  r  s     r   r'  zBSignatureTest.test_inspect_types.<locals>.doit.<locals>.<listcomp>      HHHafHHHr!   c                     g | ]	}|j         
S r   r  r  s     r   r'  zBSignatureTest.test_inspect_types.<locals>.doit.<locals>.<listcomp>  r  r!   r   r   r  r  r*   zinvalid signature for z: r  )r"   r  r   r  r  r  r  r  rV  r  r  r@  r  r  r  r  r   )typ_typec_typer'   r  r  r  r  r  r  r  r  r  kwdsr  r  r  r   r  s                 r   r  z.SignatureTest.test_inspect_types.<locals>.doit  s:   Q^^FQ^^FF *c *c??3''  .. ..%f-- %c#-f55E#-f55E #5#3#8#8#:#:;;GFFFFe.>.C.C.E.EFFFG$$Wg)H6)Q % S S S IHe.>.E.E.G.GHHHFHHe.>.E.E.G.GHHHF MM&)W555MM&)S111 Y((VABBZ-Lv-U ) W W W W ((Vc&kk-Lv-U ) W W W "(5!1!1JD$c0q		400$?$????$ c c c(jfffVZVZVZ\`\`)abbbc "(5!1!1JD$c0q		400$?$????$ c c c(jfffVZVZVZ\`\`)abbbcI%c*c *cs   H11#I,J#J0r   r.   )	r  _ParameterKindPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORDr   r   r   r  r  )r   r  r  r  r  r  r  s   ` @@@@@r   test_inspect_typesz SignatureTest.test_inspect_typest  s   $4(> aiilliill))A,,))A,,))A,,))A,,))A,,))A,,IIaLL yy||!" !0 0 aiilliill))A,,))A,,))A,,IIaLL yy||!" !
0 
014	  	  	  	  	  	  	 	 	 	-	c -	c -	c -	c -	c -	c -	c -	c -	c^ 	YYr!   N)r   r_  r`  ra  r  r  r   r!   r   r  r  S  sB         S S S8e e e e er!   r  c           	         t           |                                 }t          j        t                    D ]g}d|vs|                    d          r|                    d          \  }}t           
|t           vrE|fd}t          t          d|z   |           ~~~~hdt          fdt          ffD ]W\  }}|st          |dz   t          t          j        fd|i          }	|                    |                     |	                     Xt           vd	d
lm}
m} t          t          fD ]_}|s|fd}d }|t          u r|nd	}|t&          j        d<   |                     |
||||                     t*          t&          j        d<   `|S )Nz.decTestr  c                 <    |                      t          |z             S r   )r   	directory)r   r   s     r   r  zload_tests.<locals>.<lambda>  s    $..Q*G*G r!   test_r   Pyr;   r   r   )DocTestSuiteIGNORE_EXCEPTION_DETAILc                 $    |t           j        d<   d S Nr   )r  r2  )slfr  s     r   r   zload_tests.<locals>.setUp  s    ),I&&&r!   c                 .    t           t          j        d<   d S r  )orig_sys_decimalr  r2  )r  s    r   r   zload_tests.<locals>.tearDown  s    )9I&&&r!   )r   r   optionflags)
TODO_TESTS
suiteClassoslistdirr  r  r	  r/  r;   r   r  r:  r   TestCaseaddTestloadTestsFromTestCasedoctestr  r  r  r2  r!  )r  testspatternfilenameheadtailtesterprefixr  
test_classr  r  r   r   r"  s                  r   
load_testsr3    s   !!## Jy)) ) )X%%)<)<S)A)A%^^C((
d!d*&<&< (GGGgnf555dD&&Qx$* @ @ 	&>1'):;$c*, ,
 	f22:>>????AAAAAAAAa4 	6 	6C " - - - -: : :58AXX111K%(CK	"MM,,s%(/:< < < = = =%5CK	""Lr!   c                      t          t                     t          t                     t          t          nt	          d          ad S r  )r6   r   r  ARITHr   r-  r   r!   r   setUpModuler6    s3    GGGGGG)uu/B9/M/MHHHr!   c                  N   t           r*t                               t          t                               t                              t          t                              t           st	          j        dt                     t          t          j	        d         urt          d          d S )Nz*C tests skipped: no module named _decimal.r   zGInternal error: unbalanced number of changes to sys.modules['decimal'].)r   r3   ORIGINAL_CONTEXTr  warningswarnUserWarningr!  r  r2  r   r   r!   r   tearDownModuler<  
  s    +!,,'*
+
+
+LL!!$%%% #B!	# 	# 	#s{9555 3 4 4 	4 65r!   c                 `    | a |a|at          j        t
          |rdnddt
          g           dS )z Execute the tests.

    Runs all arithmetic tests if arith is True or if the "decimal" resource
    is enabled in regrtest.py
    r  r  F)	verbosityexitargvN)r5  r#  r0  r   mainr   arithverbose
todo_testsdebugs       r   testrG    s=     EJEM(7&9aaXJWWWWWWr!   z:test_decimal.py [--debug] [{--skip | test1 [test2 [...]]}]z--debugz-d
store_truez2shows the test number and context before each test)actionhelpz--skipz-sz%skip over 90% of the arithmetic tests)rC  rD  rB  )NNNN)ra  r  r%  r  r	  r9  r0  rn   r   r*  r  test.supportr   r   r   r   r   r   r	   r
   r   r   test.support.import_helperr   r   r   r.  r  r>  rq  r   r  r   r!  
cfractionsr2  
pfractionsr   
skipUnlessrequires_cdecimalr  r  rR  r  r2   r   r   r   r   r   r   r   r   rt  r9  r(   r   r   r   r   r   r   r/   r   r  r8  r6   TESTDATADIRr   r@  r   __file__pathdirnamecurdirtestdirsepr  isdirr   r7  hasattrEXTRA_FUNCTIONALITYr]  r  skip_if_extra_functionalityr;   rc  r'  r  r  r  r4  r6  r8  r  r  r  r  r  r-  r5  requires_working_threadingr7  rI  rK  rM  r  r  r'  r}  r  r  r*  r,  r.  r\  r^  r`  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r8  r_  r  r3  r6  r<  r5  r-  r#  r0  rG  optparseOptionParserr  
add_option
parse_argsoptr  skiprF  r   r!   r   <module>rc     sp   "               I I I I I I I I I I I I I ID D D D D D D D D D D D D D ; : : : : : ) ) ) ) ) ) ( ( ( ( ( (       <8n--- 	*666	J<888 " " " " ! [MBBB
I   [MBBB
I z1Z(	)I 'H'+DEE  16UU1<<>>$$&&'''$UU1<<>>$$&&'' 'aiAIq{AKj!"A$6 "&aiAIq{AKj!"A$6	H H H :\
m##\
 J{/ a)Q\\^^TQ\\^^ % % %  z8A;DDD
'//$


,29bf{*RV3	GMM),,,   &ga66AddE 2x2G I  I -ho46 6 a# a# a# a# a# a# a# a#LU< U< U< U< U< U< U< U<n
      8(:K       !98;L   K1 K1 K1 K1 K1 K1 K1 K1Z      8(:K       !98;L   O9 O9 O9 O9 O9 O9 O9 O9b
     *h/       :x0   hA hA hA hA hA hA hA hAT	     68I        79J   
%' %' %'N*0 *0 *0Z -,..*( *( *( *( *( *( *( /.*(Z     ]H$5       mX%6   nE nE nE nE nE nE nE nE`     ]H$5   
 
 
 
 
mX%6 
 
 
[N [N [N [N [N [N [N [Nz
     nh&7       ~x'8   hC hC hC hC hC hC hC hCT     (9       ):   b b b b b b b bH     0(2C       183D   I0 I0 I0 I0 I0 I0 I0 I0V     L("3       \8#4   N N N N N N N N`     (9       ):   <; <; <; <; <; <; <; <;|     4h6G       5x7H   k. k. k. k. k. k. k. k.Z     ,h.?       -x/@    1 1 1 1 1h' 1 1  1:               B     (+   
 
 
 
 
8, 
 
 
> > > > >h' > > >0BM BM BM BM BM" BM BM BMHSC SC SC SC SCX& SC SC SCj e e e e e! e e eN D D D D DH% D D  DN& & &PN N N4 4 4 	
X X X X zOOOZ[[ALLD<pLqqqLLD<cLddd,,..KS$
x '5$''''''	 '4$ciHHHHHH4&&&&&& r!   