403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.230
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_decimal.cpython-36.opt-2.pyc
3

�
�^
:�*@sjddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZmZddl
mZmZmZmZmZddlZddlZddlZddlZyddlZWnek
r�dZYnXeddgd�Zeddgd�ZejdZeddgd�Zeejd<eddgd�Zeejd<eeeeiZ eejd<ee�rTe!ej"�j#j$��ndee!ej"�j#j$��iZ%ee�r�ej&ej'ej(ej)ej*ej+ej,ej-ej.g	ndeej&ej'ej(ej)ej*ej+ej,ej-ej.g	iZ/d	d
�Z0ej1Z1ej2Z2ej3Z3ej4Z4ej5Z5ej6Z6ej7Z7ej8Z8e1e2e3e4e5e6e7e8gZ9ee�r*ej"�j�ndeej"�j�iZ:dd�Z;d
Z<e=dk�r^ej>dZ?ne@Z?ejAjBe?��ptejCZDeDejEe<ejEZFejAjGeF�aHdZIeJed��r�dndZKejLeKd�ZMejNeKd�ZOGdd�dejP�ZQGdd�deQ�ZRGdd�deQ�ZSGdd�dejP�ZTGdd�deT�ZUGdd�deT�ZVGd d!�d!ejP�ZWGd"d#�d#eW�ZXGd$d%�d%eW�ZYGd&d'�d'ejP�ZZGd(d)�d)eZ�Z[Gd*d+�d+eZ�Z\Gd,d-�d-ejP�Z]Gd.d/�d/e]�Z^Gd0d1�d1e]�Z_d2d3�Z`d4d5�ZaGd6d7�d7ejP�ZbejLed8�Gd9d:�d:eb��ZcejLed8�Gd;d<�d<eb��ZdGd=d>�d>ejP�ZeGd?d@�d@ee�ZfGdAdB�dBee�ZgGdCdD�dDejP�ZhGdEdF�dFeh�ZiGdGdH�dHeh�ZjGdIdJ�dJejP�ZkGdKdL�dLek�ZlGdMdN�dNek�ZmGdOdP�dPejP�ZnGdQdR�dRen�ZoGdSdT�dTen�ZpGdUdV�dVejP�ZqGdWdX�dXeq�ZrGdYdZ�dZeq�ZsGd[d\�d\ejP�ZtGd]d^�d^et�ZuGd_d`�d`et�ZvGdadb�dbejP�ZwGdcdd�ddew�ZxGdedf�dfew�ZyGdgdh�dhejP�ZzGdidj�djez�Z{Gdkdl�dlez�Z|eOGdmdn�dnejP��Z}Gdodp�dpejP�Z~Gdqdr�dre~�ZGdsdt�dte~�Z�Gdudv�dvejP�Z�Gdwdx�dxejP�Z�Gdydz�dzejP�Z�Gd{d|�d|ejP�Z�eejLed}�Gd~d�dejP���Z�eUeVeXeYe[e\e^e_ecedefegeiejelemeoepereseuevexeye{e|ee�e�e�e�e�eReSg"Z�e�s�e�d�dd��Z�ne�j�de}�e�j�d�e��d�d�d��Z�e=dk�rfddl�Z�e�j�d��Z�e�j�d�d�d�d�d��e�j�d�d�d�d�d��e�j��\Z�Z�e�j��r@e�ddd��n&e��rZe�dde�e�j�d��ne�ddd��dS)��N)�run_unittest�run_doctest�is_resource_enabled�requires_IEEE_754�requires_docstrings)�check_warnings�import_fresh_module�
TestFailed�run_with_locale�cpython_only�decimalZ_decimal)Zfresh)Zblocked�	fractionscs,t||��|jt��fdd��D���dS)Nc3s(|] }|�kr�|n�|VqdS)N�)�.0�s)�d�expectedr�1/opt/alt/python36/lib64/python3.6/test_decimal.py�	<genexpr>Psz!assert_signals.<locals>.<genexpr>)�getattr�
assertTrue�all)�cls�context�attrrr)rrr�assert_signalsNs
rcCs2|sdS|jdttjt|d�d�}|j|�dS)N�	r)�prec�rounding�traps)�Context�ROUND_HALF_EVEN�dict�fromkeys�Signals�
setcontext)�mZDefaultTestContextrrr�initgs
r'Zdecimaltestdata�__main__F�
DecClampedTz.test requires build with -DEXTRA_FUNCTIONALITYztest requires regular buildc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�IBMTestCasesc&Cs�|jj�|_|jj�|_dg|_tdddddddd	d
ddd
ddddddddddddg�|_|jtkr�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd �|jjd!�|j	|j
|j|j|j
d"�|_d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdH�%|_ttttttttdI�|_|jj|jj|jj|jj|jj|jj|jj|jj|jj|jj|jj|jj dJ�|_!dK|_"dS)LN�#Zscbx164Zscbx165Zexpx901Zexpx902Zexpx903Zexpx905Zlnx901Zlnx902Zlnx903Zlnx905Zlogx901Zlogx902Zlogx903Zlogx905Zpowx1183Zpowx1184Zpowx4001Zpowx4002Zpowx4003Zpowx4005Zpowx4008Zpowx4010Zpowx4012Zpowx4014Zpwsx803Zpwsx805Zpowx4302Zpowx4303Zpowx4342Zpowx4343Zpwmx325Zpwmx326)Z	precisionrZmaxexponentZminexponent�clamp�logical_and�_apply�number_class�compare_signal�
compare_total�compare_total_mag�copy_decimal�copy_abs�copy_negate�	copy_sign�
divide_int�logical_invert�is_canonical�	is_finite�is_infinite�is_nan�	is_normal�is_qnan�	is_signed�is_snan�is_subnormal�is_zero�max_mag�min_mag�
next_minus�	next_plus�next_toward�
logical_or�	normalize�remainder_near�same_quantum�sqrt�
to_eng_string�to_integral_value�to_integral_exact�
to_sci_string�logical_xor)%�andZapply�classZ
comparesigZcomparetotalZ
comparetotmag�copyZcopyabsZ
copynegate�copysignZ	divideint�invertZiscanonicalZisfiniteZ
isinfinite�isnanZisnormalZisqnanZissignedZissnanZissubnormalZiszeroZmaxmagZminmagZ	nextminusZnextplusZ
nexttoward�or�reduceZ
remaindernearZsamequantumZ
squarerootZtoengZ
tointegralZtointegralxZtosci�xor)ZceilingZdown�floorZ	half_downZ	half_evenZhalf_upZupZ05up)ZclampedZconversion_syntaxZdivision_by_zeroZdivision_impossibleZdivision_undefinedZinexactZinvalid_contextZinvalid_operationZoverflowZroundedZ	subnormalZ	underflow)r9r:r;r<r=r>r?r@rArBrK)#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)�selfrrr�setUp�s�	



zIBMTestCases.setUpcCsX|jtkrF|jjdkrF|jjd�|jjd�|jjd�|jj|�S|jj||�SdS)Ni@�Ti���?i�9�)	rr`�MAX_EMAXr\�_unsafe_setprec�_unsafe_setemax�_unsafe_setemin�create_decimal�Decimal)r{�vrrrr�read_unlimitedszIBMTestCases.read_unlimitedcCs�tr
tj�t|��x}xp|D]h}|jdd�jdd�}y|j|�}Wq|jjk
r�}z |jd|j	j
d|�WYdd}~XqXqWWdQRXdS)Nz
��
zException "z" raised on line )�
skip_expected�unittestZSkipTest�open�replace�	eval_liner�DecimalException�fail�	__class__�__name__)r{�file�f�line�t�	exceptionrrr�	eval_file"s

zIBMTestCases.eval_filecCs�|jd�dkrZ|dd�dkrZ|jd�rZ|jd�dd|jd�djd�dj�}n|jd�dj�}x |jD]}|j|�dkrtdSqtW|s�dSd|kr�|j|�S|j|�SdS)	Nz -> r�z--z  --z->��:)�find�
startswith�split�stripr]�eval_directive�
eval_equation)r{r�ignorerrrr�1s* 
zIBMTestCases.eval_linecCsldd�|jd�D�\}}|dkr,|j|}n"yt|�}Wntk
rLYnX|jj|dd��}||�dS)Ncss|]}|j�j�VqdS)N)r��lower)r�xrrrrDsz.IBMTestCases.eval_directive.<locals>.<genexpr>r�rcWsdS)Nr)�argsrrr�<lambda>Msz-IBMTestCases.eval_directive.<locals>.<lambda>)r�rp�int�
ValueErrorrg�get)r{r�funct�valuerrrr�CszIBMTestCases.eval_directivecs�trtj�dkrdS�jj�yt|jd�}|dj�j�}|d}trVtd|dd�|dj�}|dd�}|dj�j�}|d}|dd�}Wn"t	t
tfk
r��jj
�YnXd	d
�}	|�jkr�dS�jj||�}
|
dkr�dSt�j|
�}g}d}d}
�fd
d�|D��x t�jD]}d�jj|<�qWx�D]}d�jj|<�q:W�x8t|�D�]*\}}|jd�ddk�r�d|
}
|
�r�|d|}�q\n||}d}|	|�}|
dk�rnt�r`x��D]�}d�jj|<y|�jj|��WnR|k
�r�YnPt�jk
�r:}z�jd|||f�WYdd}~XnX�jd||f�d�jj|<�q�W�jj|�}n�j|�j�}|j|��q\W|	|�}t�r|
dk�rx��D]�}d�jj|<y||�WnR|k
�r�YnPt�jk
�r}z�jd|||f�WYdd}~XnX�jd||f�d�jj|<�q�W�fdd�t�jD�}x�|D]�}d�jj|<y||�WnV|k
�r�YnTt�jk
�r�}z�jdt|�||f�WYdd}~XnX�jd||f��q\Wx|D]}d�jj|<�q�Wt�rtd�j�y,t||��}|
�jk�r@ttt |���}WnRt�jk
�r~}z�jd||f�WYdd}~Xntd|��YnX�j!�}|j"t#d��j"t#d��j$||d|d|��j$|�d|dt|��dS)Ng�������?z->rzTest � )�endr�r�cSs@|jdd�jdd�}|jdd�jdd�}|jdd�jdd�}|S)Nz''ZSingleQuotez""ZDoubleQuote�'r��")r�)�valrrr�	FixQuotesdsz-IBMTestCases.eval_equation.<locals>.FixQuotesZrescaler�csg|]}�j|j��qSr)ryr�)rr�)r{rr�
<listcomp>tsz.IBMTestCases.eval_equation.<locals>.<listcomp>r�rPrMz Raised %s in %s when %s disabledzDid not raise %s in %scsg|]}|�kr|�qSrr)r�e)�theirexceptionsrrr��szRaised %s in %s; expected %sz--zRaised %s in %szERROR:)�keyzIncorrect answer for z -- got zIncorrect flags set in )rPrM)rPrM)%�TEST_ALL�randomr�clear_flagsr�r��DEBUG�printr��	TypeError�AttributeError�
IndexErrorrrrr_rhr�rr$r�	enumerate�count�EXTENDEDERRORTESTr�r�r��append�OrderedSignals�type�strrzr��eval�
getexceptions�sort�repr�assertEqual)r{rZSides�L�idr�Zvalstemp�ans�
exceptionsr�Zfname�valsZconglomerateZquoter��ir�r��errorr�Zordered_errors�resultZmyexceptionsr)r{r�rr�Ps�





 
 
$
"
zIBMTestCases.eval_equationcs�fdd�t�jD�S)Ncsg|]}�jj|r|�qSr)r�flags)rr�)r{rrr��sz.IBMTestCases.getexceptions.<locals>.<listcomp>)r$r)r{r)r{rr��szIBMTestCases.getexceptionscCs0|jtkr$|jjdkr$|jj|�n||j_dS)Ni@�T)rr`�MAX_PRECrr~r)r{rrrrrb�szIBMTestCases.change_precisioncCs||j_dS)N)rr)r{rrrrrc�sz#IBMTestCases.change_rounding_methodcCs0|jtkr$|jjdkr$|jj|�n||j_dS)Ni@�T)rr`r�rr��Emin)r{�exprrrre�sz IBMTestCases.change_min_exponentcCs0|jtkr$|jjdkr$|jj|�n||j_dS)Ni@�T)rr`r�rr�Emax)r{r�rrrrd�sz IBMTestCases.change_max_exponentcCs||j_dS)N)rr,)r{r,rrrrf�szIBMTestCases.change_clampN)r��
__module__�__qualname__r|r�r�r�r�r�r�rbrcrerdrfrrrrr*�s
r*c@seZdZeZdS)�
CIBMTestCasesN)r�r�r�r`rrrrrr��sr�c@seZdZeZdS)�PyIBMTestCasesN)r�r�r��Prrrrrr��sr�c@s|eZdZdd�Zdd�Zdd�Zdd�Zed	d
��Zdd�Z	d
d�Z
dd�Zdd�Ze
dd��Zdd�Zdd�Zdd�ZdS)�ExplicitConstructionTestcCs|jj}|j|�|d��dS)N�0)rr�r�)r{r�rrr�test_explicit_empty�sz,ExplicitConstructionTest.test_explicit_emptycCs|jj}|jt|d�dS)N)rr��assertRaisesr�)r{r�rrr�test_explicit_from_None�sz0ExplicitConstructionTest.test_explicit_from_NonecCs�|jj}|d�}|jt|�d�|d�}|jt|�d�|d�}|jt|�d�|d�}|jt|�d�x`tdd�D]R}xLdD]D}x>tdd
�D]0}|d||}||�}|jt|�t|��q�Wq~WqtWdS)N�-�45i{e��	500000123z-45rr�� r��r�i������)r�r����)rr�r�r��range)r{r�r�n�signr�r�rrr�test_explicit_from_int�s
z/ExplicitConstructionTest.test_explicit_from_intc
Cs�|jj}|jj}|jj}|jt|d��d�|jt|d��d�|jt|d��d�|jt|d��d�|jt|d��d�|jt|d��d	�|jt|d
��d�|jt|d��d
�|jt|d��d�|jt|d��d�x8d D]0}x*d!D]"}|jt||d|��d��q�Wq�W|���}d|j|<|j||d�|jt|ddd�|j||d�|j||d�|j||d�|j||d�|j||d�|j||d�WdQRXdS)"Nr��NaNr�z45.34Z45e2z4.5E+3�uglyz1.3E4 
z1.3E+4z  -7.89z-7.89z  3.45679  z3.45679z	1_3.3e4_0z1.33E+41Z1_0_0_0�1000r�� � z	9.311E+28T�xyz�1234r��yu1 2 3u 1 2 u  z123z1_2_3)r�r�r�r�)r�r�r�r�)	rr�rr�localcontextr�r�rr�r�)r{r�rrr�Zlead�trail�crrr�test_explicit_from_strings6


z2ExplicitConstructionTest.test_explicit_from_stringcCsRddl}|jj}|jj�}|jd�}|jt||��d�|jt|j|��d�dS)Nrz9.999999)�	_testcapirr�r �unicode_legacy_stringr�r�r�)r{r�r�rrrrr�test_from_legacy_stringsLs

z1ExplicitConstructionTest.test_from_legacy_stringscCs<|jj}|d�}|jt|�d�|d�}|jt|�d�|d�}|jt|�d	�|d�}|jt|�d�|dfd
f�}|jt|�d�|jt|d!�|jt|d#�|jt|d%�|jt||d�d&df�|jt|d(�|jt|d*�|jt|d,�|jt|d-�|jt|d/�|jt|d2�|jt|d4�|jt|d6�dS)7Nrr�r��r�z-45�r�z45.34r�z-4.34913534E-17�F�Infinity���wrong!�1r��
�a�r)rrr�r�r�)r�rr�r�r�r�r����)rrr�	r�r�r�rr�r�r�r�r����)r�rr�r�r�r�rr�)r�r	�r�r�r�rr�)r�r
r��r�r�r�rr�)r�rr�)r�r�r�rr��r�r�r�rr�)r�rr��r�r�r�rr�)r�r
r��r�r�r�rr�)r�rr)r�r�r��r�r�r�Nr�)r�rr�����r�rr�rr�)r�rr��r�rr�rr�)r�rr��r�r�r�rr�)r�rr�)rr�r�r�r�r�)r{r�rrrr�test_explicit_from_tuplesVs.z2ExplicitConstructionTest.test_explicit_from_tuplescCs�|jj}|ddgdg�}|jt|�d�|ddddddddddg	d
g�}|jt|�d	�|dddg�}|jt|�d	�|ddddddddddg	d
f�}|jt|�d	�dS)Nrr�r�r�r�rr�r�z-4.34913534E-17i��)	r�r�r�rr�r�r�r�r�i��i��)rr�r�r�)r{r�rrrr�test_explicit_from_list�s  z0ExplicitConstructionTest.test_explicit_from_listcCs\|jj}|jt|d��d�|jt|d��d�|j|d�|d��|j|d�|d��dS)NrFr�T)rr��assertIs�boolr�)r{r�rrr�test_explicit_from_bool�s
z0ExplicitConstructionTest.test_explicit_from_boolcCs�|jj}|d�}||�}|jt|�d�|d�}||�}|jt|�d�|d�}||�}|jt|�d�|d�}||�}|jt|�d�dS)	Nr�r�i{e�r�z-45rr�i���)rr�r�r�)r{r�rr�rrr�test_explicit_from_Decimal�sz3ExplicitConstructionTest.test_explicit_from_DecimalcCs6|jj}|d�}|jt|�|�|jt|�d�|j|td��j��|j|td��j��|j|td��j��|jt|td���t|d���|jt|td���t|d���|jt|td���t|d���|jt|td	���t|d
���x>t	d�D]2}t
jd�t
j
�d
d}|j|t||���q�WdS)Ng�������?z90.1000000000000000055511151231257827021181583404541015625�nan�infz-infr�r�z	-Infinityz-0.0z-0��g{�G�z�?g@g�?)rr�r�r�r�r�floatr>r;r�r��expovariate)r{r��rr�r�rrr�test_explicit_from_float�s&
z1ExplicitConstructionTest.test_explicit_from_floatcCs�|jj}|jj}|jj}tj|jj��}d|_|�}|jt|�d�|j	�}|jt|�d�|j
t|j	d�|j	d�}|j||�|j|j	d�|j	d��|d�}|jt|�d�|j	d�}|jt|�d�|jt|j	d��d	�|d*�}|jt|�d�|j	d-�}|jt|�d�|d�}||�}|jt|�d�|j	|�}|jt|�d�d|_d|j
|<x8d>D]0}|j	|�}|jt||��|jt|�|��qdWd|_d|j
|<|j
||j	d�d|_|jt|j	d��d�|jt|j	d��d�|jt|j	d��d�|jt|j	d ��d �|j
||j	d!�|j
t|j	d@�|j
t|j	d"d#�|j
||j	d$�|j
||j	d%�d|_|j
||j	d&�|j
||j	|d&��d'|j
|<|jt|j	d&��d	�|j|j|�d'|j|<|jt|j	|d&���d	�|j|j|�dS)ANr�r�i�in�z457E+2Z456789z4.57E+5z3.14
r�r�r�rr�r�z-4.34913534E-17z	-4.35E-17i{e�r�z5.00E+8�Tr��?�ri�z0E-017z0E-17r�z-Infz	-Infinity�NaN123r�r�Z5678z 1234Z12_34ZNaN12345F�	r�r�r�rr�r�r�r�r����)r�r%r&�	r�r�r�rr�r�r�r�r����)r�r'r(ll�������l���li����l��l���l������)	r)r*r+r,rr-r.r/r0���)r�r�r1)rr�rrrvrT�
getcontextrr�r�r�r�r��assertIsInstancerr�
isinstancer�r�r�)r{r�rrrv�ncrZprevdecr�rrr�$test_explicit_context_create_decimal�st










z=ExplicitConstructionTest.test_explicit_context_create_decimalcCsb|jj}|jj�}|jd�}|jt|�|�|jt|�d�|j|jtd��j	��|j|jtd��j
��|j|jtd��j
��|jt|jtd���t|jd���|jt|jtd���t|jd���|jt|jtd���t|jd���|jt|jtd	���t|jd
���d|_xBtd�D]6}t
jd
�t
j
�dd}|j|t|j|����q$WdS)Ng�������?z0.1000000000000000055511151231rrz-infr�r�z	-Infinityz-0.0z-0�drg{�G�z�?g@g�?)rr�r r�r�r�r�rrr>r;rr�r�r)r{r�r5rr�r�rrr�'test_explicit_context_create_from_float s(

z@ExplicitConstructionTest.test_explicit_context_create_from_floatcCsB|jj}dddd�}x(|j�D]\}}|jt||��|�qWdS)Nrz	0.0000372z-NaN2400)u1u٠.٠٣٧٢e-٣u-nan౨౪౦౦)rr��itemsr�r�)r{r��test_values�inputrrrr�test_unicode_digits8sz,ExplicitConstructionTest.test_unicode_digitsN)r�r�r�r�r�r�r�rr�rrrrrr r6r8r<rrrrr��s8
+Yr�c@seZdZeZdS)�CExplicitConstructionTestN)r�r�r�r`rrrrrr=Csr=c@seZdZeZdS)�PyExplicitConstructionTestN)r�r�r�r�rrrrrr>Esr>c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ImplicitConstructionTestcCs|jj}|jttdt��dS)NzDecimal(5) + None)rr�r�r�r��locals)r{r�rrr�test_implicit_from_NoneKsz0ImplicitConstructionTest.test_implicit_from_NonecCs<|jj}|jt|d�d�d�|j|d�d|d��dS)Nr�r�Z50l2}r)rr�r�r�)r{r�rrr�test_implicit_from_intOsz/ImplicitConstructionTest.test_implicit_from_intcCs|jj}|jttdt��dS)NzDecimal(5) + "3")rr�r�r�r�r@)r{r�rrr�test_implicit_from_stringWsz2ImplicitConstructionTest.test_implicit_from_stringcCs|jj}|jttdt��dS)NzDecimal(5) + 2.2)rr�r�r�r�r@)r{r�rrr�test_implicit_from_float[sz1ImplicitConstructionTest.test_implicit_from_floatcCs(|jj}|j|d�|d�|d��dS)Nr�r��2)rr�r�)r{r�rrr�test_implicit_from_Decimal_sz3ImplicitConstructionTest.test_implicit_from_Decimalc	s8|jj}Gdd�d�}|jt|�|d��d�|jt|d�|��d�|jtd�d�|jtd�d	�|jtd
�d�|jtd�d
�|jtd�d�|jtd�d�d.d/d0d1d2d3d4g}xz|D]r\}��t|��fd'd(��t|��fd)d(��|jtd*|d+�d,�d-�|jtd+|d*�d-�d,�q�WdS)5Nc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)z,ImplicitConstructionTest.test_rop.<locals>.EcSsdt|�S)Nzdivmod )r�)r{�otherrrr�
__divmod__hsz7ImplicitConstructionTest.test_rop.<locals>.E.__divmod__cSst|�dS)Nz rdivmod)r�)r{rGrrr�__rdivmod__jsz8ImplicitConstructionTest.test_rop.<locals>.E.__rdivmod__cSsdt|�S)Nzlt )r�)r{rGrrr�__lt__lsz3ImplicitConstructionTest.test_rop.<locals>.E.__lt__cSsdt|�S)Nzgt )r�)r{rGrrr�__gt__nsz3ImplicitConstructionTest.test_rop.<locals>.E.__gt__cSsdt|�S)Nzle )r�)r{rGrrr�__le__psz3ImplicitConstructionTest.test_rop.<locals>.E.__le__cSsdt|�S)Nzge )r�)r{rGrrr�__ge__rsz3ImplicitConstructionTest.test_rop.<locals>.E.__ge__cSsdt|�S)Nzeq )r�)r{rGrrr�__eq__tsz3ImplicitConstructionTest.test_rop.<locals>.E.__eq__cSsdt|�S)Nzne )r�)r{rGrrr�__ne__vsz3ImplicitConstructionTest.test_rop.<locals>.E.__ne__N)r�r�r�rHrIrJrKrLrMrNrOrrrr�EgsrPrz	divmod 10z
10 rdivmodzDecimal(10) < E()zgt 10zDecimal(10) > E()zlt 10zDecimal(10) <= E()zge 10zDecimal(10) >= E()zle 10zDecimal(10) == E()zeq 10zDecimal(10) != E()zne 10�+�__add__�__radd__�-�__sub__�__rsub__�*�__mul__�__rmul__�/�__truediv__�__rtruediv__�%�__mod__�__rmod__�//�__floordiv__�
__rfloordiv__�**�__pow__�__rpow__csd�t|�S)Nr�)r�)r{rG)�loprrr��sz3ImplicitConstructionTest.test_rop.<locals>.<lambda>cst|��dS)Nr�)r�)r{rG)�roprrr��szE()zDecimal(10)r��10)rQrRrS)rTrUrV)rWrXrY)rZr[r\)r]r^r_)r`rarb)rcrdre)rr�r��divmodr��setattr)r{r�rPZoplistZsymr)rfrgr�test_ropcs0z!ImplicitConstructionTest.test_ropN)	r�r�r�rArBrCrDrFrkrrrrr?Hsr?c@seZdZeZdS)�CImplicitConstructionTestN)r�r�r�r`rrrrrrl�srlc@seZdZeZdS)�PyImplicitConstructionTestN)r�r�r�r�rrrrrrm�srmc@s.eZdZdd�Zdd�Zedd�dd��Zd	S)
�
FormatTestc�Cs*|jj}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/�d0�d1�d2�d3�d4�d5�d6�d7�d8�d9�d:�d;�d<�d=�d>�d?�d@�dA�dB�dC�dD�dE�dF�dG�dH�dI�dJ�dK�dL�dM�dN�dO�dP�dQ�dR�dS�dT�dU�dV�dW�dX�dY�dZ�d[�d\�d]�d^�d_�d`�da�db�dc�dd�de�df�dg�dhg�}x*|D]"\}}}|jt||�|�|��q�W|jt|d�jd�dS(iNr��0E-15�0e-15�2.3E-15�2.3e-15�2.30E+2�2.30e+2�2.30000E-15�2.30000e-15�1.23456789123456789e40�1.23456789123456789e+40�1.5�1.5e+0�0.15�1.5e-1�0.015�1.5e-2�0.0000000000015�1.5e-12�15.0�1.50e+1�-15�-1.5e+1r��0e+0�0E1�0e+1�0.0�0e-1�0.00�0e-2�.6e�0.000000e-9�0.000000e+6�9.999999�9.999999e+0�	9.9999999�1.000000e+1�-1.23e5�-1.230000e+5�
1.23456789e-3�1.234568e-3r��0E-2�0.00E-8�0.0000000000�3.2E1�32�3.2E2�320�3.20E2�3.200E2�320.0�3.2E-6�	0.0000032�.6f�0.000000�.0f�
3.14159265�3�.1f�3.1�.4f�3.1416�3.141593�.7f�	3.1415926�.8f�.9f�3.141592650�g�G�0E+1�0E-5�0.00000�0E-6�0E-7�0e-7�-0E2�-0e+2�.0g�.0n�.1g�.2g�.5g�.7g�.8g�.9g�.10gr]�0%�0E0�0E-1�0E-3�0.0%�0E-4�0.00%�.3%�0.000%�0E10�0E-10�2.34�234.000%�1.234567�123.457%�.0%�1.23�123%r��-NaN123�+g�NaN456�+NaN456�.3e�Infr��.16f�-Inf�	-Infinity�-sNaNr��1.00�6�123�   123�<6�123   �>6�^6� 123  �=+6�+  123�#<10�
NaN#######�-4.3�
-4.3######�#<+10�0.0130�
+0.0130###�#< 10�
 0.0130###�@>10�
@-Infinity�#>5�?^5�?123?�%^6�%123%%� ^6�-45.6�-45.6 �/=10�
-/////45.6�/=+10�45.6�
+/////45.6�/= 10�
 /////45.6�=10�-inf�
-Infinity�^16�-Infinity�>10�1.2345�
1.2345�<10�
1.2345�,�1234567�	1,234,567�123456�123,456�12345�12,345r��1,234�12r�-1234567�
-1,234,567�-123456�-123,456�7,�8,� 123,456�08,�	0,123,456�+08,�+123,456� 08,�+09,�
+0,123,456�07,�1234.56�1,234.56�09,�	01,234.56�010,�
001,234.56�011,�0,001,234.56�012,�08,.1f�1234.5�01,234.5�
1.23456789�,%�
123.456789�12,345.6789%�,e�
1.23456e+5�,E�
1.23456E+5�a=-7.0�0.12345�aaaa0.1�	<^+15.20%r�<<+Infinity%<<<�>,%�sNaN1234567�sNaN1234567%�=10.10%r$�
   NaN123%r�s-020)r�rorp)r�rqrr)r�rsrt)r�rurv)r�rwrx)r�ryrz)r�r{r|)r�r}r~)r�rr�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�ror�)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�ror�)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�)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�)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�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r)rrr)rrr)rrr)r	rr
)rrr
)rrr)rrr)rrr)rrr)rr�r)rr�r�)rrr)rrr)rr�r�)rrr)rrr)rrr)rrr)r rr!)r"rr#)r$rr)r rr)r%rr&)r'r(r))r r(r))r*r(r+)r,r(r-)r.r(r/)r0r(r/)r1r2r3)rr4r4)r5r6r7)r8rr9)r:rr;)r<r=r>)r?rr@)rArBrC)rDr$rE)rr�r��formatr�r��
__format__)r{r�r:�fmtrr�rrr�test_formatting�szFormatTest.test_formattingc	s@�jj�yddlm}Wntk
r6�jd�YnX�fdd�}dA��fdd�	}d	|d
d
dg�dd�}d||g�d
d�}d|d
d
dg�dd�}d|ddd|g�dd�}djd�|d
d
dg�djd�d�}�j|�d�|�d��j|�d�|�d��j|�d�|�d��j|�d�|�d��j|d|�d��j|d|�d��j|d|�d��j|d|�d��j|d|d �d!��j|d|d �d"��j|d|d �d"��j|d|d �d#��j|d$|d%�d&��j|d$|d'�d&��j|d$|d(�d)��j|d$|d*�d+��j|d,|d(�d-��j|d,|d*�d-��j|d,|d.�d/��j|d,|d0�d1��j|d,|d2�d1��j|d,|d3�d4��j|d5|d*�d6��j|d5|d.�d6��j|d5|d0�d6��j|d5|d2�d7��j|d5|d3�d8��j|d5|d9�d8��j|d5|d:�d;��j|d5|d<�d=��j|�d>�|d?�d@�dS)BNr)�CHAR_MAXzlocale.CHAR_MAX not availablecs"�jtkrdjdd�|D��S|S)Nr�cSsg|]}t|��qSr)�chr)rr�rrrr�DszCFormatTest.test_n_format.<locals>.make_grouping.<locals>.<listcomp>)rr`�join)�lst)r{rr�
make_groupingCsz/FormatTest.test_n_format.<locals>.make_groupingr�cs0�jtkr�|�j||�S�|�j||d�SdS)N)�_localeconv)rr`rG)r��overriderH)r�r{rr�get_fmtFs
z)FormatTest.test_n_format.<locals>.get_fmt�.r�r)�
decimal_point�grouping�
thousands_sepr�r��&r�r�r�rTs¿zutf-8s´z12.7z12,7z1-2&7i�[z123,456,789Z	123456789z123 456 789l��c}z123456-78-9012-3z.6nz
1.23457e+8z
1,23457e+8z
1&23457e+8i�Z03nr�Z04nZ05nZ01234Z06nZ001234i90z12,345Z07nz012,345Z08nz	0,012,345Z09nZ010nz
00,012,345i@�z1-2345-6z	01-2345-6z0-01-2345-6Z011nZ012nz00-01-2345-6Z013nz
000-01-2345-6z-1.5Z020nu-0´000´000´000´001¿5)Nr�)rr��localerJ�ImportError�skipTest�decoder�)	r{rJrNrQ�en_US�fr_FR�ru_RUZcrazyZdotsep_wider)r�r{r�
test_n_format;slzFormatTest.test_n_format�LC_ALL�ps_AFcCsvddl}|jj}|j�d}|j�d}|dkrB|jdj|d��|dkr\|jdj|d��|jt|d�d	�d
�dS)NrrSrUu٫z5inappropriate decimal point separator ({!a} not {!a})u٬z1inappropriate thousands separator ({!a} not {!a})z
100000000.123r�u100٬000٬000٫123)rWrr��
localeconvrYrFr�)r{rWr�rSrUrrr�&test_wide_char_separator_decimal_point�s

z1FormatTest.test_wide_char_separator_decimal_pointN)r�r�r�rIr^r
rbrrrrrn�s Yrnc@seZdZeZdS)�CFormatTestN)r�r�r�r`rrrrrrc�srcc@seZdZeZdS)�PyFormatTestN)r�r�r�r�rrrrrrd�srdc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�ArithmeticOperatorsTestcCs�|jj}|d�}|d�}|j|||d��|j|||d��|d}|j||d��|jt|�t|��d|}|j||d��|jt|�t|��||7}|j||d��|d7}|j||d��dS)Nz-11.1z22.2z11.1r�z-6.1z16.1)rr�r�r�)r{r��d1�d2r�rrr�
test_addition�sz%ArithmeticOperatorsTest.test_additioncCs�|jj}|d�}|d�}|j|||d��|j|||d��|d}|j||d��|jt|�t|��d|}|j||d��|jt|�t|��||8}|j||d��|d8}|j||d��dS)	Nz-11.1z22.2z-33.3z33.3r�z-16.1z16.1z-38.3)rr�r�r�)r{r�rfrgr�rrr�test_subtraction�sz(ArithmeticOperatorsTest.test_subtractioncCs�|jj}|d�}|d�}|j|||d��|j|||d��|d}|j||d��|jt|�t|��d|}|j||d��|jt|�t|��||9}|j||d��|d9}|j||d��dS)Nz-5r�z-15r�z-25z-75)rr�r�r�)r{r�rfrgr�rrr�test_multiplication�sz+ArithmeticOperatorsTest.test_multiplicationcCs�|jj}|d�}|d�}|j|||d��|j|||d��|d}|j||d��|jt|�t|��d|}|j||d��|jt|�t|��||}|j||d��|d}|j||d��dS)	Nz-5�2z-2.5z-0.4r�z-1.25z-0.8z-0.625)rr�r�r�)r{r�rfrgr�rrr�
test_divisionsz%ArithmeticOperatorsTest.test_divisioncCs�|jj}|d�}|d�}|j|||d��|j|||d��|d}|j||d��|jt|�t|��d|}|j||d��|jt|�t|��||}|j||d��|d}|j||d��dS)N�5rkr�r�r�r�)rr�r�r�)r{r�rfrgr�rrr�test_floor_divisionsz+ArithmeticOperatorsTest.test_floor_divisioncCs�|jj}|d�}|d�}|j|||d��|j|||d��|d}|j||d��|jt|�t|��d|}|j||d��|jt|�t|��||C}|j||d��|dC}|j||d	��dS)
NrmrkZ25r�r�Z625rnZ16807Z390625)rr�r�r�)r{r�rfrgr�rrr�
test_powering:sz%ArithmeticOperatorsTest.test_poweringcCs�|jj}|d�}|d�}|j|||d��|j|||d��|d}|j||d��|jt|�t|��d|}|j||d��|jt|�t|��||;}|j||d��|d;}|j||d��dS)Nrmrkrr�rn)rr�r�r�)r{r�rfrgr�rrr�test_moduleVsz#ArithmeticOperatorsTest.test_modulecCs|jj}|d�}|d�}t||�\}}|j||d��|j||d��|jt|�t|��|jt|�t|��t|d�\}}|j||d��|j||d��|jt|�t|��|jt|�t|��td|�\}}|j||d��|j||d��|jt|�t|��|jt|�t|��dS)Nrmrkrr�rn)rr�rir�r�)r{r�rfrg�p�qrrr�test_floor_div_modulers$z-ArithmeticOperatorsTest.test_floor_div_modulecCsT|jj}|j|d�
|d��|j|d�|d��|jt|d��t|d���dS)Nr�r�i���i���)rr�r��abs)r{r�rrr�test_unary_operators�sz,ArithmeticOperatorsTest.test_unary_operatorscCs
|jj}|jj}|jj}|d�}|d�}|d�}|d�}||f||f||f||f||ff}||f||f||f||f||f||f||ff}	tjtjtjtjf}
tj	tj
f}x`||	D]T\}}
xJ|
|D]>}|||
�}|tj
kr�dnd}|j||dj||j
||
|��q�Wq�W|���}d|j|<x^|D]V\}}
xJ|D]B}|||
�}|tj
k�rNdnd}|j||dj||j
||
|���q0W�q"WxF|	D]>\}}
x2|D]*}|j|tj	||
�|j|tj
||
��q�W�q�Wx6||	D]*\}}
x|
D]}|j||||
��q�W�q�WWdQRXdS)	Nr��sNaNr�rkTFz8expected {0!r} for operator.{1}({2!r}, {3!r}); got {4!r}r�)rr�rrr��operator�lt�le�gt�ge�eq�nerrFr�rr�)r{r�rrr�r�rr�r�Z
qnan_pairsZ
snan_pairsZ	order_opsZequality_opsr�r��opZgotr�ctxrrr�test_nan_comparisons�sD".





z,ArithmeticOperatorsTest.test_nan_comparisonscCsH|jj}|d�j|d��}|j|d�jd�|�|jt|d�jd�dS)Nr�r�z-2rr)rr�r6r�r�r�)r{r�rrrr�test_copy_sign�sz&ArithmeticOperatorsTest.test_copy_signN)r�r�r�rhrirjrlrorprqrtrvr�r�rrrrre�s7rec@seZdZeZdS)�CArithmeticOperatorsTestN)r�r�r�r`rrrrrr��sr�c@seZdZeZdS)�PyArithmeticOperatorsTestN)r�r�r�r�rrrrrr��sr�cCs�|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}|d�}	|d�}
|	|
}|j	j
�|jj�|	|
}|���}
|j
|
j|�|j||
j|	d�|j
|
j|�|��N}|j
|j|�|j
|j|�|j||j|	|d��|j
|j|�~WdQRX|j|
j|�~
WdQRX|j||d��|j||d��|�}|j
|j|�x&||||fD]}|j|j|��qhWdS)Nr�r�rrwz0.333333333333333333333333)rr�rrrsrurxrtr2r��finish1r^�synchro�waitrr�r��divide�compare�assertFalser�)rr�rrrsrurxrtr2r�rf�d3�test1�test2�c2�c3�c1�sigrrr�thfunc1�s@

r�cCs�|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}|d�}	|d�}
|	|
}|�}d|_	|	|
}
|���}|j
|j|�|j||j
|d�d�|j
|j|�||��X}|j
|j|�|j|j|�d|j|<|j||j|d�d�|j
|j|�~WdQRX|j|j|�|j|j|�~WdQRX|jj�|jj�|j||d��|j|
|d	��|j|j|�|j
|j|�x&||||fD]}|j|j|��q�WdS)
Nr�r��Z1e425000000i�Tz1e-425000000z0.333333333333333333333333z0.333333333333333333)rr�rrrsrurxrtr2r�rrr�r��multiplyr�rr�r�r^�finish2r�)rr�rrrsrurxrtr2r�rfr�r�Zthiscontextr�r�r�r�rrr�thfunc2sH



r�c@seZdZdd�ZdS)�
ThreadingTestcCs�|jj}|jtkr&|jjr&|jd�|j}|j}|j}d|_d|_d|_tj	�|_
tj	�|_tj	�|_tj
t|fd�}tj
t|fd�}|j�|j�|jj�|jj�x"t|jD]}|j|j|�q�W|j�|j�||_||_||_dS)Nzcompiled without threading�i@�T)�targetr�i���)r�DefaultContextr`�HAVE_THREADSrYrr�r��	threadingZEventr�r�r�ZThreadr�r��startr�r$r�r�rL)r{r�Z	save_precZ	save_emaxZ	save_eminZth1Zth2r�rrr�test_threading2s2





zThreadingTest.test_threadingN)r�r�r�r�rrrrr�,sr�zthreading requiredc@seZdZeZdS)�CThreadingTestN)r�r�r�r`rrrrrr�Xsr�c@seZdZeZdS)�PyThreadingTestN)r�r�r�r�rrrrrr�[sr�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'S)(�
UsabilityTestcCs|jj}|d�}|d�}|d�}|j||�|j||�|j||�|j||�|j||�|j||�|j||�|j||�|j|d�|jd|�|j|d�|j|d�|j|d�|j|t��|j|t�t	t
|td���}|dd�}tj
|�|j�|j||�dS)Nz23.42r��r�r�g�����Y@@r7)rr��
assertGreater�assertGreaterEqual�
assertLess�assertLessEqualr��assertNotEqual�object�list�mapr�r�Zshuffler�)r{r��da�db�dcr�brrr�test_comparison_operatorsbs0
z'UsabilityTest.test_comparison_operatorscCs�|jj}|d�}|d�}|j|d�|j|d�|j|d�|j|d�|j|d�|j|d�|jd|�|jd|�|jd|�|jd|�|jd|�|jd|�|jd|d��dS)Nz0.25z3.0g@g�?g�?g�������?z0.1)rr�r�r�r�r�r�r�)r{r�r�r�rrr�test_decimal_float_comparison�s z+UsabilityTest.test_decimal_float_comparisoncCs�|jj}|d�}|d�}|j|d�|jd	|�|j|d
�|jd|�|jd|�|j|d
�|j|d�|jd|�|j|jd�t�|j|jd�t�|j|jd�t�|j|jd�t�dS)Nz0.25z3.0g�?yg�?g@y�?y�?y�?y�?y�?y@y@y@�?y@�?y@y@y@y@)	rr�r�r�rrJ�NotImplementedrLrK)r{r�r�r�rrr�test_decimal_complex_comparison�sz-UsabilityTest.test_decimal_complex_comparisonc

Cs�|jj}t|jj}|jj}|jj}|jj}tr6tjnd}trDtj	nd}trRtj
nd}|||d�}	||	���||	_|j|d�|dd��|j|dd�|d��|j|dd�|dt
|���|j|dt
|��|dd��|j|dd	�|dt
|���|j|dt
|��|dd	��|j|d
�|dd��|j|dd�|d
��d|	_|j|d�d
|dd
��|j|dd
�|d�d
�|j|dd�|dt
|���|j|dt
|��|dd��|j|d�|dd��|j|d�|dd��|j|d�|dd��|j|d�|dd��|j||d�j|dd��|jt|dd�j|d���|j|d�|dd��|j|dd�|d��WdQRXdS) Ni�ɚ;i��5w)r�r�rr�l	��Z��mH;5�BZ1ez-1el��!�0QYz0.1ri,r�i�6l�c(	Z9erl�g�]�{z-infrri6e�ilʈr�l�����g�]l�����g�]i����i����i����i����)rr�r
ZFractionr r�rrr`r}�MIN_EMIN�	MIN_ETINYrr�r�r�r�r�r�r�r�rKrr�rJ)
r{�Dr�r r�rr�emax�eminZetinyr�rrr� test_decimal_fraction_comparison�s@z.UsabilityTest.test_decimal_fraction_comparisoncCsP|jj}|d�}tj|�}|jt|�t|��tj|�}|jt|�t|��dS)Nz43.24)rr�rTr�r��deepcopy)r{r�rr�r�rrr�test_copy_and_deepcopy_methods�s

z,UsabilityTest.test_copy_and_deepcopy_methodscs�jj��jj}�fdd�}|�d��|�d��|�d��|�d��|�d���fdd	�d:D�}|j�d��d��d��d��d��d��d��d ��d!��d"��d>��d%��d&��d'��d(��d)�g�x&|D]}�j||�|t|����q�W�j|�d��|d���jtt�d*���j	|�d+����j	|�d,���d-d,d.d/d0d1d2d3g}x2|D]*}t
|�}�|�}�j||�||���qdW|��v}	�d4�}
d5|	_||
�}d6|	_||
�}d
|	_||
�}
�j||��j||
�d7|	_d8d9}
�j|�|
��||
��WdQRXdS)?Ncs t|�}|j�}�j||�|S)N)�hash�__hash__r�)rrr�)r{rr�hashit�sz.UsabilityTest.test_hash_method.<locals>.hashitr�r�z	-InfinityZnan123z-NaNcs:g|]2}tdd�D]"}dD]}�|d||��qqqS)rr�r�i����r�)r�r�)r�)rr&r�r�)r�rrr��sz2UsabilityTest.test_hash_method.<locals>.<listcomp>r�����r#r��!�=�>r"�@�A�Bz-1z-0z0.00z-0.000r�z-0E12z10.0z	-23.00000Z1230E100z
-4.5678E50r�r�z	1.634E100z
90.697E100z
188.83E100z
1652.9E100Z	56531E100rwr�z-Infrz0.0z-.0e1z34.0z2.5z
112390.625z	-0.515625z123456789.1�ri'iLi�)rr�r�r�r�r�r#r�r�r�r�r"r�r�r�llll��)rr�r��extendr�r�r�r�r�rrr)r{r�r�r:r�Ztest_stringsrr�rr�r�Zh1Zh2Zh3r)r�r{r�test_hash_method�sj


zUsabilityTest.test_hash_methodcCs�|jj}|d�}|d�}d}d}|jt||�|�|jt||�|�|jt||�|�|jt||�|�|jt||�|�|jt||�|�|jt||�|�|jt||�|�dS)Nz15.32z28.5r�r!)rr�r�min�max)r{r�rfrg�l1�l2rrr�test_min_and_max_methods4sz&UsabilityTest.test_min_and_max_methodscCs(|jj}|j|d��|j|d��dS)Nrz0.372)rr�r�r)r{r�rrr�test_as_nonzeroHszUsabilityTest.test_as_nonzerocCs4|jj}|d�}|jt|�d�|jt|�d�dS)Nz15.32zDecimal('15.32'))rr�r�r�r�)r{r�rrrr�test_tostring_methodsPsz#UsabilityTest.test_tostring_methodsc
Cs�|jj}|d�}|d�}|jt|�d�|jt|�d�|jt|�d�|jt|�d�d5d6d7d8d:d<d=d>d?g	}x&|D]\}}|jtj||��|�qtW|jttj|d��|jttj|d��|jttj|d��|jt	tj|d��|jt	tj|d��d@dAdBdCdEdGdHdIdJg	}x(|D] \}}|jtj
||��|��qW|jttj
|d��|jttj
|d��|jttj
|d��|jt	tj
|d��|jt	tj
|d��dKdLdMdNdPdRdSdTdVdXdZd[d\d]d^d_g}x&|D]\}}|jt||��|��q�W|jtt|d��|jtt|d��|jtt|d��|jt	t|d��|jt	t|d��dadcdedgdhdidjdkdldmdndodqdrg}x.|D]&\}}}	|jtt||�|��|	��qjWdS)sNZ66z15.32r�r�g�p=
ף.@�123.00r��3.2r��3.54�3.899�-2.3�-11.0��0.0r�-0E3�89891211712379812736.1��{�#'s�{Mz-NaNrwr$r��-Infr�r���{�#'s�{M�-3.5�-2.5�-1.5�-0.5�0.5�1.5�2.5�3.5�123.456�0E+4�0E+3�1E+2r��1.2E+2r��123.5�123.46�123.4560�123.455�123.445�123.44r�r��sNaN314�NaN314)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�r)r�rr)r�r)r�r)r�r)r�r�)r�r�)r�r�r�)r�r�r�r)r�rr�r)r�rr�r�)r�r�r�)r�rr�)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�mathr[r�r��
OverflowErrorZceil�roundr�)
r{r�rfrgZ
test_pairsrr�Ztest_triplesr�rrrr�test_tonum_methodsXs�z UsabilityTest.test_tonum_methodscCs\|jj}xNdD]F}t||��}|jtj|��tjd|�}|j||jd�rNdnd�qWdS)	Nr�nan1234�-nan�-nan2468g�?rT)rr�rrg�)	rr�rrr�rWrUr�r�)r{r�rr�r�rrr�test_nan_to_float�s
zUsabilityTest.test_nan_to_floatcCs0|jj}x"dD]}||�}|jtt|�qWdS)N�snan�-snan�snan1357�	-snan1234)rrrr)rr�r�r�r)r{r�rrrrr�test_snan_to_float�s
z UsabilityTest.test_snan_to_floatcCs||jj}|d
�}|j|tt|���|d�}|j|tt|���|d�}|j|tt|���|d�}|j|tt|���dS)Nrr�r�r�r�r�rr��r)rrr�r�r�)r�r	r�r�r�r�r�r)rr
r�	r�r�r�rr�r�r�r�r����)r�rr)rr�r�r�r�)r{r�rrrr�test_eval_round_trip�sz"UsabilityTest.test_eval_round_tripcCs\|jj}|d�}|j|j�d�|d�}|j|j�d�|d�}|j|j�d�|d
�}|j|j�d�|d�}|j|j�d �|d"�}|j|j�d$�|dfd
f�}|j|j�d&�|d(�}|j|j�d*�|d,�}|j|j�dfdf�|dfdf�}|j|j�dfdf�|d.�}|j|j�d0�|d2�}|j|j�d4�|d6�}|j|j�d8�dS)9Nrr�r�r�r�z-4.34913534E-17r�rr�r�r�r��%r��Nrn�r)rrri����r�r�)r�rr�	r�r�r�rr�r�r�r�r����)r�rr�r)rrr��rrr�rr�r�r�r)rrr�r�rr�r�r�r)rrr�rrr)r�rr�r)r�rr�r)r�rr�rrr�rr�r�r�)rrr��r�rr�r�r�)rrr��rrr)r�rr�r)rrr��r)rrr��r�r�r�r�)rrr��r)rr r��rr�rnr�)r�r!r��r)r�r"r�)rr�r��as_tuple)r{r�rrrr�
test_as_tuple�s6zUsabilityTest.test_as_tuplec	Cs|jj}|jt|j|d��|jt|j|d��|jt|j|d��|jt|j|d��x�td
d�D]�}x�td�D]�}x�dD]�}|d
|||f�}|j�}|\}}|j|t�|j|t	�|j|t	�|j
|d�|jtj
||�d�|j||�||�|�q|WqrWqdWdS)Nrz-infz-nanZsnan123r�r�i�rQrTz%s%dE%drr�r�)rQrT)rr�r�r��as_integer_ratior�r�r3�tupler�r�r�r�Zgcd)	r{r�r�Zcoeffr�rZpqrrrsrrr�test_as_integer_ratios*
z#UsabilityTest.test_as_integer_ratiocCsd|jj}Gdd�d|�}|d�}|d�}||}|jt|�|�|j|�}|jt|�|�tj|�}|jt|�|�|j||�tj|�}|jt|�|�|j||�|d�}||�}|jt|�|�|j||�||�}|jt|�|�|j||�|j|jd�||�}|jt|�|�|j||�d|_||�}|jt|�|�|j||�|j|jd�dS)Nc@seZdZdZdS)z1UsabilityTest.test_subclassing.<locals>.MyDecimalN)r�r�r�r�rrrr�	MyDecimal4sr(r�r�z1.0r)	rr�rr�r�rTr�r�r�)r{r�r(rfrgrr�r&rrr�test_subclassing0s<


zUsabilityTest.test_subclassingcCs@|jj}|jj}|�}|jt|d�j��t|j|d����dS)Nr)rr�r2r�r�rL)r{r�r2r�rrr�test_implicit_context_s
z#UsabilityTest.test_implicit_contextcCsf|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj	}	|jj
}
|jj}||���
��}d|_d|_
d/|_|d�}
|d�}|d�}|j�|jt|
jdd��d�|j|j|	�|j|j|
�|j�|j||jdd�|j|j|�|j|jdd�d�|j|jdd�d	�|j�|jt|
jdd��d
�|j|j|	�|j|j|
�|j�|j||d0�jdd�|j|j|�|j�|jt|
jdd��d�|j|j|	�|j|j|
�|j�|j||d1�jdd�|j|j|�|j�|jt|
jdd��d
�|j||d�jdd�|j|j|�|j�|jt|
jdd��d�|j||jdd�|j|j|�|j�|jt|jdd��d�|j||d�jdd�|j|j|�|j�|jt|jdd��d�|j||d�jdd�|j|j|�|j�|jt|jdd��d�|j||jdd�|j|j|�|jt|j dd��d�|j�|jt|j!dd��d�|j|j|�|j|j|	�|j|j|
�|j|j|�|j|j|�|j�|j||j!dd�|j|j|�d|_"|jt|j#dd��d�d|_"|j�t|
j$|d�dd��}|j|d�|j||
j$|d�dd�|j|j|�|j�t|
j%ddd��}|j|d�|j||
j%|d�dd�|j|j|�|j�t|
j&ddd��}|j|d�|j||
j&ddd�|j|j|�|j�t|
j'ddd��}|j|d�|j||
j'ddd�|j|j|�|j�t|
j(ddd��}|j|d�|j||
j(ddd�|j|j|�|j�t|
j)ddd��}|j|d�|j||
j)|d�dd�|j|j|�|j�t|
j*ddd��}|j|d�|j||
j*|d�dd�|j|j|�|j�t|
j+ddd��}|j|d�|j||
j+|d�dd�|j|j|�|j�t|
j,ddd��}|j|d�|j||
j,|d�dd�|j|j|�|j�t|
j-ddd��}|j|d�|j||j-ddd�|j|j|�|j�t|
j.ddd��}|j|d �|j||
j.ddd�|j|j|�|j�t|
j/ddd��}|j|d!�|j||
j/d"dd�|j|j|�|j�t|
j0ddd��}|j|d �|j||
j0d"dd�|j|j|�|j�t|
j1dd#dd��}|j|d$�|j||
j1|d�d#dd�|j|j|�t2|_3t|d%�j4ddd&��}|j|d
�t5|_3t|d%�j4ddd&��}|j|d'�t|d%�j4t6dd&��}|j|d
�|j�|j||d�j4dd�|j|j|�t2|_3t|d%�j7ddd&��}|j|d
�t5|_3t|d%�j7ddd&��}|j|d'�t|d%�j7t6dd&��}|j|d
�|j�|j||d�j7dd�|j|j|�t2|_3t|d%�j8ddd&��}|j|d
�t5|_3t|d%�j8ddd&��}|j|d'�t|d%�j8t6dd&��}|j|d
�|j�|j||d�j8dd�|j|j|�t6|_3t|d(�j9|d)�ddd*��}|j|d+�t5|_3t|d(�j9|d)�ddd*��}|j|d,�t|d(�j9|d)�t6dd*��}|j|d+�|j�|j||j9|d-�t6dd&�|j|j|�WdQRX||���X}d|_d|_
d2|_|dd.��0}|j|jd�|j|j
d�|j|jd3�WdQRXWdQRXdS)4Nrni�Z111Z1e9999z1e-9999)rz1.609487E+48FTz4.709530r�z2.045323rkrZ1111000z
9.999999E+999rwr�r�z
+Subnormalz0E-1005ZNan891287828Z
NaN1287828i  z-1r��eZ101r�rhr�Z11100z1.11E+9i'r�Z225z1.5)rrrz1.50001z1e-3)r�rrz1.501z1.500z1e-10)r�i���r�r�i���i���):rr�r r�rrrsrurxrwrtrvrqrr�r�r�r�r�r�rr�r�rr=rA�ln�log10�logbr8rErFrIr/rL�capitalsrMr�r0r-rHrQr�rCr�rDrJ�rotate�scaleb�shift�fmar!r�to_integralrjrnrNrO�quantize)r{r�r r�rrrsrurxrwrtrvrqr�r�r��zr�rrrr�test_none_argshs�zUsabilityTest.test_none_argscCs |jj}|j|d�jd�|d�j|d���|j|d�jd�|d�j|d���|j|d�jd�|d�j|d���|j|d�jd�|d�j|d���|j|d�jd�|d�j|d���|j|d�jd�|d�j|d���|j|d�j	d�|d�j	|d���|j|d�j
d�|d�j
|d���|j|d�jd�|d�j|d���|j|d�jd�|d�j|d���|j|d�j
d�|d�j
|d���|j|d�jd�|d�j|d���|j|d�jd�|d�j|d���|j|d	�jd�|d	�j|d���|j|d�jd
�|d�j|d
���|j|d�jd�|d�j|d���|j|d�jd�|d�j|d���|j|d
�jd�|d
�j|d���|j|d�j|d�d�|d�j|d�|d���|j|d�jdd�|d�j|d�|d���|j|d�jd|d��|d�j|d�|d���dS)Nr�r�iu'i�i7r�i�r7ir�i�z9.123i��r��Ci����i����r�r�i�i�i�i�i�i�)rr�r�r�r0r1r2r-rHrQr�rCr�rDrGr5rJr0rKr1r2r3)r{r�rrr�test_conversions_from_intW	sVz'UsabilityTest.test_conversions_from_intN)r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
r$r'r)r*r7r:rrrrr�_s($*	Tg
-!/	pr�c@seZdZeZdS)�CUsabilityTestN)r�r�r�r`rrrrrr;�	sr;c@seZdZeZdS)�PyUsabilityTestN)r�r�r�r�rrrrrr<�	sr<c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�PythonAPItestscCsT|jj}|jt|tj��|jt|tj��|j|d�tj�|j	|d�tj�dS)Nr)
rr�r�
issubclass�numbers�Numberr�ZRealr3ZassertNotIsInstance)r{r�rrr�test_abc�	s
zPythonAPItests.test_abccCs��x�ttjd�D�]�}|jj}tjd}|jtjd<|d�}tj||�}tj|�}|j	||�t
�r�t
jd�}tjd�}t
tjd<tj||�}	ttjd<tj|	�}
|j|
tj�|j	|
|�ttjd<tj||�}t
tjd<tj|�}
|j|
t
j�|j	|
|�t
jd�j
�}tjd�j
�}t
tjd<tj||�}	ttjd<tj|	�}
|j|
tj�|j	|
|�ttjd<tj||�}t
tjd<tj|�}
|j|
t
j�|j	|
|�|tjd<qWdS)Nr�rz-3.141590000z-3.123e81723)r��pickle�HIGHEST_PROTOCOLrr��sys�modules�dumps�loadsr�r`r�r3r#ZDecimalTuple)r{�protor��savedecimalrrrr�r�r�ZsxrZsyrrr�test_pickle�	sL















zPythonAPItests.test_picklecCs�|jj}x`tdd�D]R}d|d}|jt||��tt|���||�}|jt�}|j|t|��|�qW|jt	t|d��|jt	t|d��|jt
t|d��|jt
t|d��dS)	N�z%0.2fgY@z-nanrrz-infi���)rr�r�r�r�rr4rjr�r�r�)r{r�r�rrrrrr�test_int�	s
zPythonAPItests.test_intcCsp|jj}xbtdd�D]T}d|d}|jt||��tt|���||�}|jt�}|j|tj	|��|�qWdS)NrKz%0.2fgY@i���)
rr�r�r�r�rr4rjr�Ztrunc)r{r�r�rrrrrr�
test_trunc�	s
zPythonAPItests.test_trunccCs�|jj}Gdd�d|�}|jt||��|jd�}|jt|�|�|jt|�d�|j|jd�d}|j|j|�||��|j|jt	d��j
��|j|jt	d��j��|j|jt	d	��j��|jt|jt	d���t|d
���|jt|jt	d���t|d���|jt|jt	d	���t|d���|jt
|jd
�xBtd�D]6}tjd�tj�dd}|j|t	|j|����qBWdS)Nc@seZdZdd�ZdS)z1PythonAPItests.test_from_float.<locals>.MyDecimalcSs
d|_dS)Nr�)r�)r{�_rrr�__init__�	sz:PythonAPItests.test_from_float.<locals>.MyDecimal.__init__N)r�r�r�rOrrrrr(�	sr(g�������?z90.1000000000000000055511151231257827021181583404541015625r�ls\�&�5$3�|	rrz-infr�r�z	-Infinity�abcrg{�G�z�?g@g�?)rr�rr>�
from_floatr�r�r�r�rr>r;r�r�r�r�r)r{r�r(rZbigintr�r�rrr�test_from_float�	s.

zPythonAPItests.test_from_floatcCs�|jj}|jj}|jj}|dtd�}|j|jtj�|d��|dt	d�}|j|jtj�|d��|d|gd�}|j
||jtj�|jt|jd��d�|jt|jd��d	�|jt|jd
��d�dS)
Nr�)rrz3.1415z3.1416)rrgz
Decimal('-0')g�?zDecimal('1')rz
Decimal('10')g�)rr�r rtrjr��create_decimal_from_floatr�Zpirnr�r�)r{r�r rtrrrr�test_create_decimal_from_float
s,



z-PythonAPItests.test_create_decimal_from_floatcCs�|jj}|jj}|jj}|ddd�}|j|d�j|d��|d��|j|d�j|d�td�|d��|j||d�j|d	�|d
�|�}|d�}|j||d�td
�}|j||d��dS)Ni��)r�r�z7.335z.01z7.34)rz7.33Z10e99999Z1e100000)rz0.871831e800Z1e797)rr�rz	8.71E+799iay��)rr�r rrr�r5rjr�)r{r�r rrr�rr�rrr�
test_quantize#
s"

zPythonAPItests.test_quantizecCs�|jj}|d�}|j|j|�|j|jd�|j|j�|�|d�}|jt|�ttd���|jt	t
|dd�|jt	t
|dd�|jt	t
|dd�|jt	t
|d	d�dS)
Nz9.8182731e181273rrr��realr7�imag�	conjugate�__complex__)rr�r�rVrWrX�complexrr�r�rj)r{r�r�rrr�test_complex;
szPythonAPItests.test_complexc
Cs|jj}|jj}|jj}|jj}|jj}|�}d|_d|_d6|_|����}|j	�|j
|d|�d�|j
|d|d�d�|j
||dd�d�|j
||d�d�|j	�|j||d|d�|j|j
|�|j|j
|�|j	�|j
|d�j|d�d�|j||d	�j|d�|j|j
|�|j|j
|�|j	�|j
|d�j|d�|d
��|j||d7�j|d�|j|j
|�|j|j
|�|j
|d�j|d�|d��|j
|d8�j|d�d9�|j
|d:�j|d�|d��|j
|d
�j|d�|d��|j
|d�j|d�d�|j
|d�j|d�d;�|j
|d�j|d�d�|j
|d�j|d�|d��|j
|d�j|dd�d<�|j	�|j||d�j|d�|d�|j|j
|�|j|j
|�|j
|d�j|d�|d�|d��|j
|d�j|d�|d�|d��|j
|d�j|d�|d�|d��|j
|d�j|d �|d�|d!��|j
|d�j|d �|d�|d��|j
|d�j|d"�|d�|d#��|j	�|j||d�j |d$�|d�|j|j
|�|j|j
|�|j
|d%�j!|d&�|d�|d'��|j
|d(�j"|d)�|dd*�|d+��|jt#|d�j$|d�|jt#|d�j%|d�|jt#|d�j&|d�|jt#|d�j'|d�|jt#|d�j(|d�|jt#|d�j)|d�|jt#|d�j*|d�|jt#|d�j+|d�|j|d�j,|d��|j|d�j-|d��|jt#|d�j.|d�|jt#|d�j/|d�|jt#|d�j0|d�|j
|d=�j1|d�d�|j
|d�j2|d�d�|j
|d�j3|d�d-�|j
|d.�j4|d�d.�|j
|d/�j5|d0�|d�d�|j
|d/�j6|d0�|d�d�|j
|d1�j7|d0�|d�d�|j
|d2�j8d|d�d�|j
|d2�j8d|d�d�|j	�|j||d2�j9d|d�|j|j
|�|j|j
|�|j
|d2�j:d>|d�d�|jt#|j;d3|d�|jt#|d�j<|d�|j
|d�j=�d�|jt#|d"�j>|d�|jt#|d"�j?|d�|jt#|d�j=d4d�|jt#|d�j=d4d5�WdQRXdS)?Nr�r)r)rr�rr�r�rnr�z0.7z-infz-0.9z9.73z1E+1Z9999i'z-2000i�r�r�z0.0625z0.2r�)rrGr�rz0.01z0.0101z0.0z-0.3z0.02z-0.03z-0.0z-1z0.1Z1e10z9.99z1.5z-0.5z9.9z0.9)�thirdrrGz7E+1�oz
+Subnormalz0.21Z11rhZ01Z23g�������?r�)r�r�r�r�rr�i0���r�i����r�)@rr�r r�rrrurr�r�r�r�r�rr�r�r�r,r-rErFrIr4rOrNrLr�r0r�rCr�rDrGr5rJr3r�r9r:r;r<r>r@r?rBr=rA�adjustedrX�radixr.r8r/rMr-rHrQr0r1r2rQr#�	canonicalr4r5)r{r�r r�rrruZxcr�rrr�test_named_parametersK
s�
""
"
"

z$PythonAPItests.test_named_parameterscCs�|j}|j}|j}|j}|j}|j}|j}|j}|j}	|j	}
|j
}|jt|t
��|jt||��|jt||��|jt|t��|jt||��|jt|t��|jt||
��|jt||	��|jt||��|jt||	��|jt||
��|jt||��|jt||��|jt||��|jt|	|��|jt|
|��|jt||��|jt|j|��|jt|j|��|jt|j|��|jt|jt��|jt|j|��dS)N)rr�rr�FloatOperationrsrurxrwrtrvrqrr>�ArithmeticErrorr��ZeroDivisionErrorZConversionSyntaxZDivisionImpossibleZDivisionUndefinedZInvalidContext)r{rr�rrrbrsrurxrwrtrvrqrrr�test_exception_hierarchy�
sBz'PythonAPItests.test_exception_hierarchyN)
r�r�r�rArJrLrMrRrTrUr[rarerrrrr=�	s3 pr=c@seZdZeZdS)�CPythonAPItestsN)r�r�r�r`rrrrrrf�
srfc@seZdZeZdS)�PyPythonAPItestsN)r�r�r�r�rrrrrrg�
srgc@seZdZdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdN�Z*dOdP�Z+dQdR�Z,dSdT�Z-dUdV�Z.dWdX�Z/dYdZ�Z0d[d\�Z1d]d^�Z2d_d`�Z3dadb�Z4dcdd�Z5dedf�Z6dgdh�Z7didj�Z8dkdl�Z9dmdn�Z:dodp�Z;dqdr�Z<dsdt�Z=dudv�Z>dwdx�Z?dydz�Z@d{d|�ZAd}d~�ZBdS)��ContextAPItestsc
Cs�|jj}|jj}|jj}|jj}|�}|ddddddddd�}x�||gD]z}|j|jd�|j|jt�|j|j	d�|j|j
d�|j|jd�|j|jd�t
||dg�t
||d|||g�qHWdS)	N)rrr�r�r/r,r�rr!i?Br�rr�ri���)rr rrrsrur�rrr!r�r�r/r,r)r{r rrrsrur�r�r�rrrr7�
s"
zContextAPItests.test_none_argscCsvddl}|jj�}x&tD]}|j|�|_|j|j|�qW|jd�}|jtt	|d|�|jd�}|jtt	|d|�dS)Nrr�rz	ROUND_UP)
r�rr �
RoundingModesr�rr�r�r�rj)r{r�r�Zrndrrrrr��
s



z(ContextAPItests.test_from_legacy_stringscCs��x�ttjd�D�]�}|jj}tjd}|jtjd<|�}tjtj||��}|j	|j
|j
�|j	|j|j�|j	|j|j�|j	|j
|j
�|j	|j|j�|j	|j|j�|j	|j|j�|j	|j|j�tr�ttfttfgnttfg}�x�|D�]�\}}�x�tt�D�]|\}	}
�xntt|�D�]\\}}
�xNtt|�D�]<\}}
tjdd�}
tjd	d�}tjdd�}tjd�}tjd�}|tjd<|j|
||t|	||t|d|�t|d|�d�}tj||�}|tjd<tj|�}|j||j�|j	|j
|
�|j	|j|�|j	|j|�|j	|j
t|	�|j	|j|�|j	|j|�t||dt|d|��t||dt|d|���q>W�q$W�q
Wq�W|tjd<qWdS)
Nr�rr7rr�)rr�r�rr/r,r�rr�ri����)r�rBrCrr rDrErGrFr�rr�r�rr/r,r�rr`r�r�rir�r��	randranger3r)r{rHr rIr�r��combinationsZdumper�loaderZrirN�fiZtirr�r��capsr,rrrrrrJ
sX





0zContextAPItests.test_picklecCsB|jj}|j|d�dd|d�dig�|j|d�dddig�dS)Nrrg�?r�r�)r�r�)r�r�)rr�ZassertInZassertNotIn)r{r�rrr�test_equality_with_other_typesJsz.ContextAPItests.test_equality_with_other_typescCs�|jj}|jj}|�}|j�}|jt|�t|��|jt|j�t|j��|jt|j�t|j��t|jj	��}t|jj	��}|j
||�|j
|j|j�dS)N)rr�r rTr�r�r�rr^�keysr�)r{r�r r�rZk1Zk2rrr�	test_copyPszContextAPItests.test_copycCs"|jj}|�}|jtt|d�dS)NZ_clamp)rr r�r�r)r{r r�rrr�test__clamp_szContextAPItests.test__clampcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nr�z-1r�r�)rr�r rur�r�r�)r{r�r r�rrrr�test_absjszContextAPItests.test_abscCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r)rr�r rar�r�r�)r{r�r r�rrrr�test_addsszContextAPItests.test_addcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r)rr�r r�r�r�r�)r{r�r r�rrrr�test_compareszContextAPItests.test_comparecCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r)rr�r r0r�r�r�)r{r�r r�rrrr�test_compare_signal�sz#ContextAPItests.test_compare_signalcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r)rr�r r1r�r�r�)r{r�r r�rrrr�test_compare_total�sz"ContextAPItests.test_compare_totalcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r)rr�r r2r�r�r�)r{r�r r�rrrr�test_compare_total_mag�sz&ContextAPItests.test_compare_total_magcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nr�z-1r�r�)rr�r r4r�r�r�)r{r�r r�rrrr�
test_copy_abs�szContextAPItests.test_copy_abscCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nr�z-1r�r�)rr�r r3r�r�r�)r{r�r r�rrrr�test_copy_decimal�sz!ContextAPItests.test_copy_decimalcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nr�z-1r�r�)rr�r r5r�r�r�)r{r�r r�rrrr�test_copy_negate�sz ContextAPItests.test_copy_negatecCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd	�|jt|jdd�dS)
Nr�r�rz-2rrrrr)rr�r r6r�r�r�)r{r�r r�rrrrr��szContextAPItests.test_copy_signcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r r�r�r�r�)r{r�r r�rrrr�test_divide�szContextAPItests.test_dividecCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r r7r�r�r�)r{r�r r�rrrr�test_divide_int�szContextAPItests.test_divide_intcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r rir�r�r�)r{r�r r�rrrr�test_divmod�szContextAPItests.test_divmodcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r�r�r�r�)r{r�r r�rrrr�test_exp�szContextAPItests.test_expcCs^|jj}|jj}|�}|j|d�|d�|d��}|j|jddd�|�|j|j|d�dd�|�|j|jd|d�d�|�|j|jdd|d��|�|j|j|d�|d�d�|�|jt|jddd�|jt|jddd�|jt|jddd�|jt|j|d�|d�d	�|jt|j|d
�|d�d�|jt|d�j|d�d	�|jt|d
�j|d�d�dS)
Nr�r�r�rkr��4r�rz
not a decimalr�rgZd;�O��?)rr�r r3r�r�r�)r{r�r r�rrrr�test_fmas(

zContextAPItests.test_fmacCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r:r�r�r�)r{r�r r�rrrr�test_is_finiteszContextAPItests.test_is_finitecCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r;r�r�r�)r{r�r r�rrrr�test_is_infinite&sz ContextAPItests.test_is_infinitecCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r<r�r�r�)r{r�r r�rrrr�test_is_nan/szContextAPItests.test_is_nancCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r=r�r�r�)r{r�r r�rrrr�test_is_normal8szContextAPItests.test_is_normalcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r>r�r�r�)r{r�r r�rrrr�test_is_qnanAszContextAPItests.test_is_qnancCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r?r�r�r�)r{r�r r�rrrr�test_is_signedJszContextAPItests.test_is_signedcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r@r�r�r�)r{r�r r�rrrr�test_is_snanSszContextAPItests.test_is_snancCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r rAr�r�r�)r{r�r r�rrrr�test_is_subnormal\sz!ContextAPItests.test_is_subnormalcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r rBr�r�r�)r{r�r r�rrrr�test_is_zeroeszContextAPItests.test_is_zerocCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r,r�r�r�)r{r�r r�rrrr�test_lnnszContextAPItests.test_lncCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r-r�r�r�)r{r�r r�rrrr�
test_log10wszContextAPItests.test_log10cCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r r.r�r�r�)r{r�r r�rrrr�	test_logb�szContextAPItests.test_logbcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r)rr�r r-r�r�r�)r{r�r r�rrrr�test_logical_and�sz ContextAPItests.test_logical_andcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Ni�r�)rr�r r8r�r�r�)r{r�r r�rrrr�test_logical_invert�sz#ContextAPItests.test_logical_invertcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r)rr�r rHr�r�r�)r{r�r r�rrrr�test_logical_or�szContextAPItests.test_logical_orcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r)rr�r rQr�r�r�)r{r�r r�rrrr�test_logical_xor�sz ContextAPItests.test_logical_xorcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r r�r�r�r�)r{r�r r�rrrr�test_max�szContextAPItests.test_maxcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r rCr�r�r�)r{r�r r�rrrr�test_max_mag�szContextAPItests.test_max_magcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r r�r�r�r�)r{r�r r�rrrr�test_min�szContextAPItests.test_mincCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r rDr�r�r�)r{r�r r�rrrr�test_min_mag�szContextAPItests.test_min_magcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r Zminusr�r�r�)r{r�r r�rrrr�
test_minus�szContextAPItests.test_minuscCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r r�r�r�r�)r{r�r r�rrrr�
test_multiply�szContextAPItests.test_multiplycCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r rEr�r�r�)r{r�r r�rrrr�test_next_minus�szContextAPItests.test_next_minuscCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r rFr�r�r�)r{r�r r�rrrr�test_next_plus
szContextAPItests.test_next_pluscCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r rGr�r�r�)r{r�r r�rrrr�test_next_toward

sz ContextAPItests.test_next_towardcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r rIr�r�r�)r{r�r r�rrrr�test_normalize
szContextAPItests.test_normalizecCsn|jj}|jj}|�}|j|jd�|j|d���|j|jd�|j|d���|j|jd�|j|d���dS)Nr�rr�i���i���)rr�r r�r/)r{r�r r�rrr�test_number_class"
sz!ContextAPItests.test_number_classcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r �plusr�r�r�)r{r�r r�rrrr�	test_plus+
szContextAPItests.test_pluscCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|j|j|d�|d��|�|jt|jdd�|jt|jdd�|j|jdddd�d�dS)	Nr�r�rr�r�r�r�)�modulor�r)rr�r �powerr�r�r�)r{r�r r�rrrr�
test_power4
szContextAPItests.test_powercCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r r5r�r�r�)r{r�r r�rrrrrUB
szContextAPItests.test_quantizecCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r Z	remainderr�r�r�)r{r�r r�rrrr�test_remainderN
szContextAPItests.test_remaindercCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r rJr�r�r�)r{r�r r�rrrr�test_remainder_nearZ
sz#ContextAPItests.test_remainder_nearcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r r0r�r�r�)r{r�r r�rrrr�test_rotatef
szContextAPItests.test_rotatecCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r rLr�r�r�)r{r�r r�rrrr�	test_sqrtr
szContextAPItests.test_sqrtcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r rKr�r�r�)r{r�r r�rrrr�test_same_quantum{
sz!ContextAPItests.test_same_quantumcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r r1r�r�r�)r{r�r r�rrrr�test_scaleb�
szContextAPItests.test_scalebcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r r2r�r�r�)r{r�r r�rrrr�
test_shift�
szContextAPItests.test_shiftcCs�|jj}|jj}|�}|j|d�|d��}|j|jdd�|�|j|j|d�d�|�|j|jd|d��|�|jt|jdd�|jt|jdd�dS)Nr�r�rrk)rr�r �subtractr�r�r�)r{r�r r�rrrr�
test_subtract�
szContextAPItests.test_subtractcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r rMr�r�r�)r{r�r r�rrrr�test_to_eng_string�
sz"ContextAPItests.test_to_eng_stringcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r rPr�r�r�)r{r�r r�rrrr�test_to_sci_string�
sz"ContextAPItests.test_to_sci_stringcCsJ|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�dS)Nrrh)rr�r rOr�r�r�)r{r�r r�rrrr�test_to_integral_exact�
sz&ContextAPItests.test_to_integral_exactcCs\|jj}|jj}|�}|j|d��}|j|jd�|�|jt|jd�|jt|jdd�dS)Nrrhr�)rr�r rNr�r�r�)r{r�r r�rrrr�test_to_integral_value�
sz&ContextAPItests.test_to_integral_valueN)Cr�r�r�r7rr�rJrorqrrrsrtrurvrwrxryrzr{r�r|r}r~rr�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�rUr�r�r�r�r�r�r�r�r�r�r�r�rrrrrh�
s~=																												rhc@seZdZeZdS)�CContextAPItestsN)r�r�r�r`rrrrrr��
sr�c@seZdZeZdS)�PyContextAPItestsN)r�r�r�r�rrrrrr��
sr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ContextWithStatementcCsb|jj}|jj}|�}|��}|�}WdQRX|�}|j||d�|j||d�|j||d�dS)Nz!did not restore context correctlyzdid not copy the contextz __enter__ returned wrong context)rr2r�r�assertIsNot)r{r2r��orig_ctx�	enter_ctx�set_ctx�	final_ctxrrr�test_localcontext�
sz&ContextWithStatement.test_localcontextc	Cs�|jj}|jj}|jj}|jj}|�}|dd�}||��}|�}WdQRX|�}|j||d�|j|j|jd�|j||d�|j||d�dS)N�*)rz!did not restore context correctlyzdid not set correct contextzdid not copy the contextz __enter__ returned wrong context)rr r2r�rr�rr�)	r{r r2r�r��new_ctxr�r�r�rrr�test_localcontextarg�
s

z)ContextWithStatement.test_localcontextargcCs�|jj}|jj}|jj}|jj}|jj}|jj}|�}|j�|dd�}|���}	|j|	j	|j	�|j|	j
|j
�d|	j
|<d|	_|j|jd	�|j
||	jd�|j|	j	|�||��^}
|j|
j	|j	�|j|
j
|j
�|j
||
j|d�d�|j|
j	|�|j|
j	|�~
WdQRX|j|	j	|�~	WdQRX|j|jd
�|j|j	|�|j|j	|�|j|j	|�|j|j	|�dS)Ni�)r�Tiz0e-999z3.4e200r�i����i����i����)rr�r r2r�rqrur�r�r�rr�r�r�r�rr�r�)r{r�r r2r�rqrur�r�r�r�rrr�test_nested_with_statements�
s>


z0ContextWithStatement.test_nested_with_statementscCs\|jj}|��D}~|��0}~|��}~|��}~WdQRXWdQRXWdQRXWdQRXdS)N)rr�)r{r�r�r�r��c4rrr�test_with_statements_gc1sz-ContextWithStatement.test_with_statements_gc1cCsb|jj}|��J}||��6}~||�� }~||��
}~~WdQRXWdQRXWdQRXWdQRXdS)N)rr�)r{r�r�r�r�r�rrr�test_with_statements_gc2&s


z-ContextWithStatement.test_with_statements_gc2c
Cs"|jj}|jj}|jj}|jj}|���}~|dd�}||�||���}~|j|jd�~|dd�}||�~|j|�jd�|dd�}	||	�|j|�jd�||	��^}
~	|j|
jd�~
|dd�}||�~|j|�jd�|��}|j|jd�~WdQRXWdQRXWdQRXWdQRXdS)Nr�)rr�r�r�)rr r�r2r%r�r)
r{r r�r2r%r�Zn1r�Zn2Zn3r�Zn4r�rrr�test_with_statements_gc32s<





z-ContextWithStatement.test_with_statements_gc3N)	r�r�r�r�r�r�r�r�r�rrrrr��
s
#r�c@seZdZeZdS)�CContextWithStatementN)r�r�r�r`rrrrrr�Ssr�c@seZdZeZdS)�PyContextWithStatementN)r�r�r�r�rrrrrr�Usr�c@s8eZdZdd�Zdd�Zedd��Zdd�Zd	d
�ZdS)�ContextFlagsc
s��jj}�jj}�jj}�jj}�jj}�jj}�jj}�fdd�}|dddtggd�}	|	j	|d�gf|	j
|d�gf|	j|d�|d	�gf|	j|d�|d	�gf|	j
|d�|d	�gfg}
|g|g|g|g|g|||||gg}x�|
D]�\}}
|	j�||
�}d
d�|	jj�D�}x�|D]�}|	j�x|D]}||	|��q"W||
�}t|�}x"|D]}||k�rL|j|��qLW|jtd�d
d�|	jj�D�}|jtd��j||dd||f��j||dd||f��qWq�WdS)Ncs2�jtkr$d|j|<|j|r.|�n
|j|�dS)NT)rr`r�rZ_raise_error)r�flag)r{rr�raise_errores



z7ContextFlags.test_flags_irrelevant.<locals>.raise_errorri@�T)rr�r�rrr�z100E-425000010r�z
1.23456789z
9.87654321cSsg|]\}}|r|�qSrr)r�kr�rrrr��sz6ContextFlags.test_flags_irrelevant.<locals>.<listcomp>)r�cSsg|]\}}|r|�qSrr)rr�r�rrrr��sz=operation produces different answers depending on flags set: zexpected %s, got %s.z9operation raises different flags depending on flags set: zexpected %s, got %si���)rr�r rtrvrxrqrwr!r.rLrar�r�r�r�r9r�r�r�r�r�)r{r�r rtrvrxrqrwr�rZ
operationsZflagsets�fnr�r�r��extra_flagsr�Znew_ansZexpected_flagsZ	new_flagsr)r{r�test_flags_irrelevantZsN



z"ContextFlags.test_flags_irrelevantcCs2|jj}|jj}|jj}|�}|j|j|j�|j|j|j�|j|_|j|j|j�|j|j|j�d|j|<|j|_|j|j|j�|j|j|j�i}|j|j�|j||j�|j|j|�d||<|j||j�|j|j|�|di}|j||j�|j|j|�dg}|j||j�|j|j|�dS)NTFr�)	rr rtrvr�r�rr��update)r{r rtrvr�rrrr�test_flag_comparisons�s4
z"ContextFlags.test_flag_comparisonscCs�|jj}|jj}|jj}|����}|j|j|�|j�|j|d�d�|j|j	|�|j�|j|j
d�d�|j|j	|�|j�|jd�}|j|j	|�|j|d�|j|j	|�|j�|jd�}|j|j	|�|j|d�|j|j	|�d|j|<|j�|j
||d�|j|j	|�|j�|j
||j
d�|j|j	|�|j�|jd�}|j|j	|�|j�|jd�}|j|j	|�WdQRXdS)Ng@T)rr�rbr�r�rr�r�rr�r�rQrSr�)r{r�rbr�r�r�rrr�test_float_operation�sD





z!ContextFlags.test_float_operationcs"�jj��jj}�jj��jj}d��fdd�	��d���d��d�
d��d���d��	d	�d�
�d
���d��td��td
��d���������	�
��
��fdd�	}d���fdd�	}|�}||��P}�j|j��||dd�||dd�d|j�<||�d�||�d�WdQRXdS)NcsN|j�t||�}|�kr*�j|||�n�j||�d��j|j��dS)NT)r�rr�rrr�)rr�rr�signalr�)rbr{rr�assert_attr�s
z7ContextFlags.test_float_comparison.<locals>.assert_attrz0.25z3.0g�?g@z0.0z-0.0gr�z	-Infinityrz-infcsxdD]}��
�|||�qWxdD]}���|||�q$W��
�d|d����	d|d����
d|d����	d|d����
d|d����d|d����d|d���
�d|d���d�dd|d����d|d����d|d���d	�td
�d|d�dS)
NrJrLrKrMrNrOz0.1g�������?r�r)rJrL)rKrM)r)r�r�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_frr�doits 

z0ContextFlags.test_float_comparison.<locals>.doitcs�|j�td�d�g�}�jt|�d��j|j��|j�|r\�j|td�d�g�ntd�d�g�}�j|j��|j�d�d�dgk}�j|j��|j�d�d�dddik}�j|j��dS)	NgY@z100.0r�g�?z10.0g$@rr�)r�r^r��lenrr�r��sorted)r�r�rr�)r�rbr{rr�test_containers4sz;ContextFlags.test_float_comparison.<locals>.test_containers)r�T)Ng�)N)N)rr�r rbr�rr�r)r{r r�r�r�r5r�r)r�rbr�r�r�r�r�r�r�r�r�r{r�r�r�r�r�test_float_comparison�s6	(

z"ContextFlags.test_float_comparisoncCs�|jj}|jj}|jj}|jj}|�}|j|j|�|j|j|�|j�d|j|<d|j|<|j	|j|�|j	|j|�dS)NT)
rr�r rtrbr�r�r�clear_trapsr)r{r�r rtrbrrrr�test_float_operation_defaultSs

z)ContextFlags.test_float_operation_defaultN)	r�r�r�r�r�rr�r�r�rrrrr�Xs
B&6[r�c@seZdZeZdS)�
CContextFlagsN)r�r�r�r`rrrrrr�csr�c@seZdZeZdS)�PyContextFlagsN)r�r�r�r�rrrrrr�esr�c@seZdZdd�Zdd�ZdS)�SpecialContextscCs|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj	}	t
||d|||||	g�|�j�}
|j}|j}d}
zxyJd|_|_x8||fD],}||�|�}|j
||�|j|jd�q�WWn(tk
r�}z|j}
WYdd}~XnXWd||_||_||
�|
�r|
�XdS)Nri�)r�BasicContext�ExtendedContextr2r%rrrsrurxrqrrTrr�r��	Exceptionr�)r{r�r�r2r%rrrsrurxrq�savecontextZbasic_context_precZextended_context_prec�ex�templater�r�rrr�test_context_templatesks:
z&SpecialContexts.test_context_templatescCs&|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}|j	|j
d�|j	|j
d�t||d|||g�|�j�}	|j
}
d}z�yR|�}|j
}
d|_
|�}|j	|j
|
�||�|�}|j
||�|j	|j
d�Wn*tk
�r}z|j}WYdd}~XnXWd|
|_
||	�|�r |�XdS)Nrri�)rr�r�r�r2r%rrrsrur�rrrTr�r�r�)r{r�r�r�r2r%rrrsrur�Zdefault_context_precr�r�Zsaveprecr�rrr�test_default_context�s>
z$SpecialContexts.test_default_contextN)r�r�r�r�r�rrrrr�hs$r�c@seZdZeZdS)�CSpecialContextsN)r�r�r�r`rrrrrr��sr�c@seZdZeZdS)�PySpecialContextsN)r�r�r�r�rrrrrr��sr�c@seZdZdd�ZdS)�ContextInputValidationc	CsR|jj}|jj}|j�}xNdD]F}t||d�|jt||�d�|jtt||d�|jt	t||d�qWt|dd�|jt|d�d�|jtt|dd�|jt	t|dd�|jt	t|d	d �|jt	t|d	d
�|jt	t|d	d�|jt	t|d	d�xJd!D]B}|jtt||d"�|jtt||d�|jt	t||dddg��q�W|jt
t|dd�|jt	t|dg�|jtt|di�|jtt|dddi�xd#D]}|jt
|j|��q�W|jt	t|d
�|jt	t|d
�|jt	|dd�|jt	|dd�|jt|dd�|jt|d$d�|jt|dgd�|jt|dgd�|jt	|d%d�|jt	|d&d�dS)'Nrr�i?Br�r�r�r�r�rrg�?r/r,r�r7r�rrrr)r)r,)r/r�)r��Q)r)rr�r�i���i���)r�r�r�r�)r/r,r�)rr�r�rr/r,r�rr�)rr�)r�r)
rr r�rTrjr�rr�r�r�r��KeyError�__delattr__)r{r r�r�rrrr�test_invalid_context�sL


z+ContextInputValidation.test_invalid_contextN)r�r�r�r�rrrrr��sr�c@seZdZeZdS)�CContextInputValidationN)r�r�r�r`rrrrrr��sr�c@seZdZeZdS)�PyContextInputValidationN)r�r�r�r�rrrrrr��sr�c@seZdZdd�ZdS)�ContextSubclassingcs�|j��j}�j��j}�j}�j}�j}�j}�j}�j	}�j
}	G��fdd�d��}
��}|
�}x$d$D]}
|jt||
�t||
��qjW|j
t|
fdd%i�|
dd�}|j|jd�|j
|	|j|d
�d�|j
t|
fddi�|
tdd�}|j|jt�|j|j|d��d�|j
t|
fddi�|
d&dd�}|j|jd'�|j|d�|d��}|j||d��x(|||||fD]}|j|j|��qrW|j
t|
fdd(i�|
ddd�}|j|jd�|j
||j|d�|d��|jtk�rx$|||fD]}|j|j|��q�W|j
t|
fdd)i�|
dd�}|j|jd�|jd�}|j|j|�d�|j
t|
fddi�|
ddd �}|j|jd�|j|d��}|jt|�d!�|j
t|
fd	di�|
||gd"�}x"||fD]}|j|j|��q�W|j �x"t!�D]}|j"|j|��q�W|j
t|
fd
di�|
||gd#�}x"||fD]}|j|j#|��q8W|j$�x"t!�D]}|j"|j#|��qdWdS)*NcseZdZd��fdd�	ZdS)z>ContextSubclassing.test_context_subclassing.<locals>.MyContextNc		s��j|�|dk	r||_|dk	r&||_|dk	r4||_|dk	rB||_|dk	rP||_|dk	r^||_�dk	r�t�t�r��fdd�t	��D���|_
�dk	r�t�t�r��fdd�t	��D���|_dS)Ncsi|]}|�k|�qSrr)rr�)r�rr�
<dictcomp>"sz[ContextSubclassing.test_context_subclassing.<locals>.MyContext.__init__.<locals>.<dictcomp>csi|]}|�k|�qSrr)rr�)rrrr�&s)rOrrr�r�r/r,r4r�r�r�r)	r{rrr�r�r/r,r�r)r r)r�rrrOs*


zGContextSubclassing.test_context_subclassing.<locals>.MyContext.__init__)NNNNNNNN)r�r�r�rOr)r rrr�	MyContextsr�rrr�r�r/r,r�rr�)rZ9e2r�XYZ)rrz9.9rr�)r�rz1e-99z2.234e-2000z0.0)r�rZ1e99z
2.234e2000)r/Z1E222z1e+222r��c)r,r�z!1.000000000000000000000000000E+99)r�)r)rrr�r�r/r,r�rr�r�r�r�r�)%rr�r rqrsrtrurvrwrxrrr�rr�r�rr5r�rjrr�r�rarr�r�r`r/r�rPr,r�r�r�r�rr�)r{r�rqrsrtrurvrwrxrrr�r�rrr�r�r)r rr�test_context_subclassings~


z+ContextSubclassing.test_context_subclassingN)r�r�r�r�rrrrr�sr�c@seZdZeZdS)�CContextSubclassingN)r�r�r�r`rrrrrr�msr�c@seZdZeZdS)�PyContextSubclassingN)r�r�r�r�rrrrrr�osr�c@s$eZdZdd�Zdd�Zdd�ZdS)�CheckAttributescCs�|jtjtj�|jtjtj�|jtjtj�|jtjtj�|jtjdkpVtjdk�|jtjdkpptjdk�|jtj	tj	�|jt
t�t
t��dS)NTF)r�r`r�r�r}r�r�rr��__version__�dir)r{rrr�test_module_attributesusz&CheckAttributes.test_module_attributescCsJdd�ttj��D�}dd�ttj��D�}|jt|�t|�t��dS)NcSs$g|]}d|ks|jd�r|�qS)�__rN)r�)rrrrrr��sz;CheckAttributes.test_context_attributes.<locals>.<listcomp>cSs$g|]}d|ks|jd�r|�qS)rrN)r�)rrrrrr��s)r�r`r r�r�r^)r{r�r�rrr�test_context_attributes�sz'CheckAttributes.test_context_attributescCsNdd�ttjd��D�}dd�ttjd��D�}|jt|�t|�t��dS)NcSs$g|]}d|ks|jd�r|�qS)rrN)r�)rrrrrr��sz;CheckAttributes.test_decimal_attributes.<locals>.<listcomp>rcSs$g|]}d|ks|jd�r|�qS)rrN)r�)rrrrrr��s)r�r`r�r�r^)r{r�r�rrr�test_decimal_attributes�sz'CheckAttributes.test_decimal_attributesN)r�r�r�rrrrrrrr�rsr�c@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�CoveragecCsH|jj}|j|d�j�d�|j|d�j�d�|j|d�j�d�dS)NZ	1234e9999i'rrr)rr�r�r^)r{r�rrr�
test_adjusted�szCoverage.test_adjustedcCsL|jj}|jj}|d�j�}|j|d�|�}|j|d��}|j|d�dS)Nr)rr�r2r`r�)r{r�r2r�r�rrr�test_canonical�szCoverage.test_canonicalcCst|jjj�}d|_d|_d|_t|_d|_d|_	x&t
|jD]}d|j|<d|j|<q<W|j
�}d}|j||�dS)Ni@�Trr�Fz{Context(prec=425000000, rounding=ROUND_HALF_DOWN, Emin=-425000000, Emax=425000000, capitals=0, clamp=1, flags=[], traps=[])i���)rr�rTrr�r�rlrr/r,r�r�r�__repr__r�)r{r�r�rr�rrr�test_context_repr�s
zCoverage.test_context_reprcCs|jj}|jj}|����}d|_d|_d!|_|jt|d��d�|j|d�dd�|j|d�dd�|j|d�d	d�|j|d
�j|d�d�d�|j	|d�jd	d�j
�d
�|jt|d�dd	�d�|j|d�j�d�|j	|d�j
�d�|j	|d�j�d
�|j|d�j�d�|j|d�j�d�|j|d�j�d�|j|d�j�d�|j|d�d�|j|d�dd�|j|d�j�d�|j|d�j�|d��|j|d�j�|d��|j|d�j�d�|j|d�
d"�|j|d�d	d�|j|d�d	d�|j|d�j�d�|j|d�j��|j|d�j��|j|d�j��|j|d�j��|j|d�j��|j|d�j��|j|d�j��WdQRX|��`}d|_dd }||�}|j�}|j||�|j�}|j||�|j |d��}|j||�WdQRXdS)#Nr�z-10r�7r�rhr�r�rnz1.2z0.01r�Tz1.01r�FZ20Z580rkr�rz2E+1z-1E+1z+Normalz-1z1.12345rrr�i'i�i�r�r�)!rr�r�rr�r�r�rur3rr<�powr�r=rAr,r-r.r8rErFrIr/rOrr9r:r@r?rBr4r5r6)r{r�r�r�r�r�r6rrrr*�s^

zCoverage.test_implicit_contextcCs�|jj}|jj}|jj}|jj}|����}t|d�d�\}}|j||d��|j||d��t|d�d�\}}|j|j�o�|j��d|j	|<t|d�d�\}}|j|j�o�|j��d|j	|<|j
�t|d�|d��\}}|j|j�o�|j��|j|j|�|j
�t|d�d	�\}}|j|j��o2|j��|j|j|�|j
�t|d
�d
�\}}|j|j��ot|j��|j|j|�d|j	|<|j
�t|d�d
�\}}|j|j��o�|j��|j|j|�o�|j|�WdQRXdS)NZ10912837129i�Z10901935Z194r�rnFrr+rr�)
rr�r�rrrsrir�rr<rr�r�r;)r{r�r�rrrsr�rsrrrrr~	s@



zCoverage.test_divmodcCs�|jj}|jj}|jj}|jj}|���}d|_|j�|j|d�d|d��|j|j	|�d|_d|_
d
|_|j�d|j|<|j|d�|d�|d	��|j|j	|�WdQRXdS)Nr�z1.0r7z1.00r�Fi'z0.5rr�)
rr�r�rurvrr�r�rr�r�r�r)r{r�r�rurvr�rrrr�2s 
zCoverage.test_powerc
Csj|jj}|jj}|jj}|��B}d|_d|_d|_d|j|<|d�j|d��}|j	|j
��WdQRXdS)Nr�Fr�Z1e1r�)rr�r�rrrr�r�rr5rr<)r{r�r�rrr�r�rrrrUFs
zCoverage.test_quantizecCs>|jj}|jj}|�}|j|d�j�d�|j|j�d�dS)Nrr)rr�r2r�r_)r{r�r2r�rrr�
test_radixSs
zCoverage.test_radixcCs4|jj}x&dD]}|jt|d	�|�d
�t�qWdS)NrSrVrYr\rIr_rbrerr�)rSrVrYr\rIr_rbre)rr�rrr�)r{r�rrrrrk[szCoverage.test_ropcCs�|jj}|jj}|���}d|_|jt|d�j��d�|jt|d�j��d�|jt|d�jd��d�|jt|d	�jd
��d�|jt|d	�jd��d�|jt|d
�jd�|jt|d
�jdd�WdQRXdS)Nr!z9.99rhz9.99e-5r�z
1.23456789r�z1.23457z1.2345rz1.2345000000z0E+10z1.23rmr�i����)	rr�r�rr�r��	__round__r�r�)r{r�r�r�rrr�
test_roundbszCoverage.test_roundcCs |jj�}|jt|jdg�dS)Nr])rr r�r�r�)r{r�rrr�test_create_decimalss
zCoverage.test_create_decimalc
Cs`|jj}|jj}|��@}d|_|dd�dd}|jt|�d�|j|j�d�WdQRXdS)Ni'i�i�riSr�r�)rr�r�rr�r�r4)r{r�r�r�r�rrrrLwszCoverage.test_intcCsl|jj}|�}d|_dd}|j|�}|j||�|j|�}|j||�|j|d�}|j||�dS)Ni'i�i�r�)rr rr4r�r5r6)r{r r�r�r�rrrrq�s


zCoverage.test_copyN)r�r�r�rrrr*r~r�rUrrkr
rrLrqrrrrr�sQ)

rc@seZdZeZdS)�	CCoverageN)r�r�r�r`rrrrrr�src@seZdZeZdS)�
PyCoverageN)r�r�r�r�rrrrrr�src@seZdZdd�ZdS)�PyFunctionalitycCsRtj}tj}ddddddddddg
}x(|D] \}}}|jt||�|�|�q*WdS)N�.0e�1.0�1e+0�#.0e�1.e+0�.0fr�#.0f�1.r��1.1�#g�.0g�#.0g�.0%�100%�#.0%�100.%)rrr)rrr)rrr)rrr)r�rr)rrr)rrr)rrr)rrr)r rr!)r�r�r�r�rF)r{r�r�r:rHrr�rrr�test_py_alternate_formatting�sz,PyFunctionality.test_py_alternate_formattingN)r�r�r�r"rrrrr�src@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
PyWhiteboxcCs�tj}tj}|���}d|_|d�|d�}|j||d��|d�|d�}|j||d��|d�|d�}|d	�|d
�}|j||d��|d�|d
�}|d
d�|d
�}d|_|d�|d�}d|_|dd�|d�}WdQRXdS)Nr�r�r�z-0.5z
0.00390625z-0.6z0.0012885819Z256e7l�o�
�z-0.0625z0.2Z152587890625e7r�ic
r�Z152587890625��iBii)r�r�r�rr�)r{r�r�r�r�rrr�test_py_exact_power�s"zPyWhitebox.test_py_exact_powercs:tj}tj}tj}|j�}tdd�ttD��|_||�|d��|d��|d��|d��d4�����fdd�	}|���j�j	�j	��j�j
�j
��j�j�j�|d�|d	d
�|dd
�|dd
�|d
d
�|dd
�|dd
�|dd
�|dd
�|d�|dd
�|d�|d�|d�|dd
�|dd
�|d�|d�|d�|dd
�|dd
�|dd
�|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
�|d0d
�|d1�|d2�|d3�dS)5Ncss|]}|dfVqdS)rNr)rrrrrr�sz=PyWhitebox.test_py_immutability_operations.<locals>.<genexpr>z-25e55z33e+33Fcs�|rvtd|d��j�j�j��j�j�j��j�j�j��j�j�j��j�j�j��j�j�j�n@td|d��j�j�j��j�j�j��j�j�j�dS)Nzd1.z(d2)z())r�r��_sign�_int�_exp)Z	operationZuseOther)�b1�b2rfrgr{rr�checkSameDec�sz@PyWhitebox.test_py_immutability_operations.<locals>.checkSameDec�__abs__rRTrHrNrOrLrJrMrK�	__float__rar��__int__�	__trunc__r^rX�__neg__�__bool__�__pos__rdrSrIrrbr_rYrerV�__str__rUr[r^r#r�r�r�rIr5rJrKrLrMr4)F)r�r�r�r%rTr"r�rr�r&r'r()r{r�r�r%r�r+r)r)r*rfrgr{r�test_py_immutability_operations�st


























z*PyWhitebox.test_py_immutability_operationscCs>tj}|d�}||�}|jt|�d�|jt|�t|��dS)Nr�r�)r�r�r�r�r�r�)r{r�rr�rrr�test_py_decimal_ids
zPyWhitebox.test_py_decimal_idc
Cs@tj}tj}|��$}|d�jdt�}|j|j��WdQRXdS)Nr�r�)r�r�r�Z_rescalernrr<)r{r�r�r�r�rrr�test_py_rescale#s
zPyWhitebox.test_py_rescalecCs tj}|jt|d�jdt�dS)Nz3.1234r)r�r�r�r�Z_roundrn)r{r�rrr�test_py__round,szPyWhitebox.test_py__roundN)r�r�r�r%r4r5r6r7rrrrr#�s
O	r#c@s0eZdZedd��Zedd��Zedd��ZdS)�CFunctionalitycCstj}tj}tj}tj}dd�}||�}|j|jd�|j|jd�|j|jd�|||�||�}|j|jd�|j|jd�|j|jd�|||�||�}|j|jd	�|j|jd
�|j|jd�|||�|j	t
|d�|j	t|d�|j	t|d�dS)NcSs.|j|jd�t||dg�t||dg�dS)Nr�rr�)r�r,r)r{rrrr�assert_rest=sz7CFunctionality.test_c_ieee_context.<locals>.assert_restrn�`�_r�i�i�"ii�r�r"r�ii����i����i�lr�)r`�IEEEContext�	DECIMAL32�	DECIMAL64�
DECIMAL128r�rr�r�r�r�r�)r{r=r>r?r@r9r�rrr�test_c_ieee_context5s.


z"CFunctionality.test_c_ieee_contextcCs:tj}|tjtjd�}|j|jtj�|j|jtj�dS)N)r�r)r`r r)�
DecRoundedr��_flags�_traps)r{r r�rrr�test_c_contextYszCFunctionality.test_c_contextcCstjtjtjtjtjtjtjtjtj	tj
tjtjtj
tjtjf}|jtjd�|jtjd�|jtjd�|jtjd�x$t|�D]\}}|j|d|>�q�W|jtjtjtjBtjBtjBtjBtj	Btj
B�|jtjtjtjB�|jtjtjtjBtjB�dS)Nr�r��ir�)r`r)�DecConversionSyntax�DecDivisionByZero�DecDivisionImpossible�DecDivisionUndefined�DecFpuError�
DecInexact�DecInvalidContext�DecInvalidOperation�DecMallocErrorZDecFloatOperation�DecOverflowrB�DecSubnormal�DecUnderflowr�r>r?r@ZIEEE_CONTEXT_MAX_BITSr��DecIEEEInvalidOperationZ	DecErrorsZDecTraps)r{�condr�r�rrr�test_constantsas("

zCFunctionality.test_constantsN)r�r�r��requires_extra_functionalityrArErUrrrrr82s$r8c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
d��Z
dd�Ze	dd��Zdd�Z
dd�Zdd�Zdd�Zdd�Ze	dd��Ze	dd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+S),�	CWhiteboxcCs�tj}tj}dd}dd}|��Z}d|_xLtd�D]@}tj||�}tjdd�}||}	||�||�}
|j|	|
�q4WWdQRXdS)Nr�#�$i@Br�i�i�)r`r�r�rr�r�rjr�)r{r�r�r)r*r�r�rr�r�r�rrr�test_bignum�szCWhitebox.test_bignumcCs|jttjdd�dS)Nrr�)r�r�r`r�)r{rrr�test_invalid_construction�sz#CWhitebox.test_invalid_constructioncCs@tj}tj}tj}tj}||���|j||d�WdQRXdS)NZ1e9999999999999999999)r`r�rrr r�r�)r{r�rrr r�rrr�test_c_input_restriction�sz"CWhitebox.test_c_input_restrictioncCs�tj}tj}|j�}d|_d|_d|_t|_d|_	d|_
x$ttD]}d|j|<d|j
|<qBWd|j|<d|j
|<|j�}d}|j||�dS)Ni@�Trr�TaQContext(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])i���)r`r�rbrTrr�r�rlrr/r,r�r�rrr�)r{r�rbr�r�rr�rrr�test_c_context_repr�s"


zCWhitebox.test_c_context_reprc	Cstj}tj}tj}tj}tj}tj}tj}tjdk}|�}	|j	t
|	jjdd�|j	t
|	j
jdd�|j	t|	jj|�|j	t|	j
j|�|j	tt|	ddg�|j	tt|	ddg�|j	t
t|	dddi�|j	t
t|	dddi�|	jj�}
|
|=d	|
d
<|j	t
t|	d|
�|j	t
t|	d|
�|�r d&nd(}|�r.d)nd*}x d+D]}
|j	tt|	|
|��q8W|j	tt|	d|�|j	t||d�|j	t||d�|j	t||d�|j	t||dd�|j	t||dd�|j	t||dd�|j	t||dd�|j	t||dd�xrd,D]j}
|j	tt|	|
|d�|j	tt|	|
|d�tjdk�r|j	tt|	|
|�|j	tt|	|
|d��qWtjdk�r�|j	tt|	d�|d�|j	tt|	d�|d�|j	tt|	d�|d�tjdk�rN|j	tt|	d�d�|j	tt|	d�d�|j	tt|	d�d-�|j	tt|	d�d�|j	tt|	d�d.�|j	tt|	d�d�xtd/D]l}
|j	tt|	|
d0�|j	tt|	|
d�|j	tt|	|
ddd g�|�rT|j	tt|	|
d1�|j	tt|	|
d3��qTW|j	ttd"t��|j	ttd#t��|�}|j	t|d$�||�dS)4Ni@�Ti!rr�r�rr�r�i�pr�r�r"r#rr�rrr�r�)r)r�)r�)r,)r/r/r,�win32r~rr�i���?r�r�zwith localcontext("xyz"): passz-with localcontext(context=getcontext()): passr�ll����li���l�N�Zoiʚ;)rr�)rr�r�r/r,r�i9�)r/r,r�lll)r`r rrrurbr�r2r%r�r�r�r��__setitem__rr��__delitem__r�rjrTr�rD�platformr�execr@)r{r rrrurbr�r2r%�HAVE_CONFIG_64r�r�int_maxZgt_max_emaxrZ
saved_contextrrr�test_c_context_errors�s�







zCWhitebox.test_c_context_errorscCs�|jtjtj�|jtjtj�|jtjtj�|jtjtj�|jtjtj�|jtjtj�|jtj	tj	�|jtj
tj
�dS)N)rr`rnr�rjrirkrmrlr!ro)r{rrr�test_rounding_strings_interned+sz(CWhitebox.test_rounding_strings_internedcCs�tj}tj}tj}tj}tj}tj}tjdk}|�}|r<dnd}	|jt	t
|d|	d�|jt	t
|d|	d�tjdkr�|jt
t
|d|	�|jt
t
|d|	d�xndD]f}
|jt	t
||
|	d�|jt	t
||
|	d�tjdkr�|jtt
||
|	�|jtt
||
|	d�q�W|jt
t
|dd�|jt
t
|dd�|jtt
|dddd
g�|�rx|jt
t
|dd�|jt
t
|dd�x2dD]*}
|jtt
||
d�|jtt
||
d
��q~WdS)Ni@�Tr�r"r�r#�_allcrr^rCrDr�r�i?Br�ll����li���)rCrDr�lll)rCrD)r`r rrrur�r2r%r�r�r�rjrDrar�r�)r{r rrrur�r2r%rcr�rdrrrr�test_c_context_errors_extra6s:




z%CWhitebox.test_c_context_errors_extracCstj}tj}tj}tj}tj}tj}|j�}d|_t	|_
d|_d	|_d|_
d|_|j|jd�|j|j
t	�|j|jd
�|j|jd�|j|j
d�|j|jd�|j|j�d�|j|j�d�tjdk�r|jd�|jd�|jd�|j|jd�|j|jd�|j|jd
�dS)Nr<i�r�ri�i�i@�Ti�ɚ;iH�iH�i'�i6e�i6e�)r`r�rqrxrtrvrwrTrrmrr�r�r/r,r�ZEtinyZEtopr�r~rr�)r{r�rqrxrtrvrwr�rrr�test_c_valid_contextas8


zCWhitebox.test_c_valid_contextcCs4tj}|j�}|j|jd�d|_|j|jd�dS)Nr�r)r`r�rTr�rg)r{r�r�rrr�test_c_valid_context_extra�s
z$CWhitebox.test_c_valid_context_extrac
Cs�tj}tj}tj}tj}tj}tjdkr,d
nd}|���}d|j|<|j||d�j	|d�|j||d�j	|�|j||d�j	t
|d��|jtj|d�j	t
|d��|jt|d�j	|d�|jt|d�j	|d�WdQRXdS)
Ni@�Tr�r"r�r#Tz1.23rll����li���)r`r�rrr�r}r�r�rr�rr�r�)r{r�rrr�r}r�rdr�rrr�test_c_round�s(
zCWhitebox.test_c_roundcCs�tj}tjdk}|jt|d�jdgd�|jt|d�jdd�|jt|d�jg�|jt|d�jd�|rndnd}|jt|d	�jd
|�dS)Ni@�Tr�z=10.10rz<>=10.10r�r"r#z
1.23456789z=%d.1ll����li���)r`r�r�r�r�rGr�)r{r�rc�maxsizerrr�
test_c_format�s
zCWhitebox.test_c_formatcCsPtj}tj}tj}|d�}|j|j�d�|jt|jd�|jt|jdd�|jt|jd�|j|j�d�|jt|jd�|jt|jdd�|jt|jd�|j|j	�d�|jt|j	d�|jt|j	dd�|jt|j	d�|��`}|d�jt
�}|j||d��|d�j	t
�}|j||d��d|j|<|j||d�j	t
�WdQRXdS)Nrrhr�z99999999999999999999999999.9Z100000000000000000000000000Tz999.9)r`r�rtr�r�r4r�r�rNrOrnr)r{r�rtr�r�r�rrr�test_c_integral�s.
zCWhitebox.test_c_integralcCs>tj}tj}tj}tj}tj}|j|d�j�d�|jt	t
|d�dd�|jt	|d�jdd�|jt	|d�jd	dd�|jt	|d
�j
|d�g�|jt	|d
�j
|d�|��|jt	|d
�j
|d�d�|jt	|d
�j
|d�td
�|���J}|j�|jt	|j|d�dd�|jt	|jd�|jt	|jd�|jt	|jdddd�|jt	|jdd	dd�|jt|j|d���d�|j|j�d�d|j|<|j||d�jd�|j||jdd�|j|j|�|j�d|j|<|j||d�jd�|j||jdd�|j|j|�d|j|<d|_|j|t
|d
�dd�WdQRXdS)Nz9.99e10z99.9E+9r�r�r�rr�r�r�z
1.23456789z	1e-100000ri�rr�Z200Tri�)r`r�rrrsr2r�r�rMr�r�r
r/rKr5rnr�r6r`r9rir�r_rrHrr�r�r)r{r�rrrsr2r�r�rrr�test_c_funcs�sT



zCWhitebox.test_c_funcsc
Cs�tj}tj}|d�}x8d"D]0}t||�}|jt|dd�|jt|ddd�qWx8d#D]0}t||�}|jt|dd�|jt|ddd�qTW|jt|jdgd�|jt|jigd�|jt|jgg�|jt|jdgd�|jt|jigd�|jt|jgg�|jt|jdgd�|jt|jigd�|jt|jgg�|jt|j	dddd�|jt|j	ddddd�|jt|j
dgdd�|jt|j
dgdd �|jt|j
dgg�|�}|jt|jdddd!�|jt|jdddd!�|jt|jdddd!�dS)$NZ10001111111r�r=rAr,r-r.r8rErFrIr/rLrMr�)rr�r0r-rHr�rCr�rDrJr0r1r2)rrr�r�)r)�mod)
r�r=rAr,r-r.r8rErFrIr/rLrM)r�r0r-rHr�rCr�rDrJr0r1r2)r`r�r rr�r�r4rNrOr3r5r�)r{r�r r�r�funcr�rrr�test_va_args_exceptionssB

z!CWhitebox.test_va_args_exceptionscCsL|jtjjtjtjBtjBtjBtjB�|jtj	jtjtjBtjB�dS)N)
r�r`r�rDrSrHrPrRr)r�)r{rrr�test_c_context_templates<s z"CWhitebox.test_c_context_templatesc%sDtj}tj}tj}tj}tj}tj}tj}tj}tj	}	tj
}
tj}tj}tj
}
�fdd�}|j�}�j||jk�|j�x|jj�D]}d|j|<q�Wx|jj�D]}�j|�q�W|j�x |jj�D]\}}�j|�q�W�j|jj|���j|jjd�d��j|jjdd�d��jt|jjddd��jt|j�t|j��tj|j�}tj|j�}|jj�}|j �||_!�j|j|
�|j�||_"�j|j|�|j �|jj�}d||<||_|||j�|j�|jj�}d||<||_|||j�|
tj|tj#|	tj$|tj%|tj&|tj'|tj(|tj
i}tj)tj*tj+tj,tjtj-tj.g}tt/t�}�xxt0|�D�]j}�x`t0|�D�]R}�xHt1D�]>}t2j3t/t|�}t2j3t/t|�}t2j4dd�}t2j4dd	�}t2j4d	d�}t2j4d	d
�}t2j4d	d
�} t2j4d	d
�}!|||||| |t5|�t5|�d�}�j|j6|��j|j7|��j|j8|��j|j9|��j|j:| ��j|j;|�d	}"x|D]}#|"||#O}"�qxW�j|j!|"�d	}"x|D]}#|"||#O}"�q�W�j|j"|"��q�W�q~W�qlWx0|D](}$|$|_!�j|j!|
@�|||j��q�Wx0|D](}$|$|_"�j|j"|
@�|||j��qWdS)
Ncs8x2|D]*}||kr"�j||�q�j||�qWdS)N)rr�)r�Zsignal_dictr�)r{rr�assertIsExclusivelySet\s
z<CWhitebox.test_c_signal_dict.<locals>.assertIsExclusivelySetTr�r�r6r�i'rr�)rrr�r�r/r,r�ri���)<r`r r�rrrsrurwrxrvrtrqr)rNrSrTrrr�rp�valuesr9r�r�r�rr�r�r�r�rD�	getsizeofrr�rCrDrBrLrQrRrPrHrIrJrKrMrOrGr�r�rir�Zsamplerjr�rrr�r�r/r,)%r{r r�rrrsrurwrxrvrtrqr)rNrSrtr�r�r�rrZ
IntSignalsZIntCondZlimrr�r�r�rrr�r�r,rnZcrr�r�rTr)r{r�test_c_signal_dictHs�







 

zCWhitebox.test_c_signal_dictcs�tj�yddlm}Wntk
r4|jd�YnXdd�}d�fdd�	}d	|d
d
dg�d	d�}d|d
d
dg�d	d�}d|d
d
dg�dd�}|dkr�|jt|d|d�|jt|d|d�|jt|d|d�dS)Nr)rJzlocale.CHAR_MAX not availablecSsdjdd�|D��S)Nr�cSsg|]}t|��qSr)rK)rr�rrrr��szJCWhitebox.test_invalid_override.<locals>.make_grouping.<locals>.<listcomp>)rL)rMrrrrN�sz6CWhitebox.test_invalid_override.<locals>.make_groupingr�cs�|�j||�S)N)rG)r�rPrH)r�rrrQ�sz0CWhitebox.test_invalid_override.<locals>.get_fmtr�)rSrTrUZxxxxxr�rRZyyyyy�i90r�)Nr�)r`r�rWrJrXrYr�r�)r{rJrNrQZinvalid_groupingZinvalid_dotZinvalid_sepr)r�r�test_invalid_override�s*
zCWhitebox.test_invalid_overridecCs�tj}tj}tj}|��|}d|j|<dtj}|j|||�dtjd}|j|||�dtj}|j|||�dtjd}|j|||�WdQRXdS)NTz0e%dr�z1e%d)r`r�r�rrrrDrlr�)r{r�r�rrr�r�rrr�test_exact_conversion�s


zCWhitebox.test_exact_conversioncCs�tj}tj}tj}tj}tj}|����}d|j|<d|j|<d|j|<dftjf}|j	t
|j|��d�|j|||�dd
tjf}|j||j|�|j|||�dftjdf}|j	t
|j|��d�|j|||�ddtjdf}|j||j|�|j|||�dftjdf}|jt
|j|�|jt
||�dftjdf}|jt
|j|�|jt
||�dfdf}|j	t
||��d�d
}|j	t
||��d�d}|j	t
||��d	�WdQRXdS)NTr�z
-0E+999999rr�z-0E-1000007rz-sNaNz-sNaN1)rr�r�)rr�r��r)r�r|r�rr�)r�r}r)r`r�r�rrrurxrrDrlr�r�r�r�r�)r{r�r�rrrurxr�r�rrr�test_from_tuple	sB




zCWhitebox.test_from_tuplecCs�tj}tjdk}|j|d�j�d�|rZ|dd
�j�}|dd�j�}|j||d�n0|dd�j�}|dd
�j�}|j||d	�dS)Ni@�Trr�r�r�r�rr�i�i�����)r`r�r�r��
__sizeof__r�)r{r�rcr�r�rrr�test_sizeof9s
zCWhitebox.test_sizeofcs~tj}Gdd�dt�}Gdd�dt�}Gdd�dt��G�fdd�dt�}x.|||fD] }|j|j|d	��|jd	��qVWdS)
Nc@seZdZdd�Zdd�ZdS)z<CWhitebox.test_internal_use_of_overridden_methods.<locals>.XcSsdS)Nr�r)r{rrrr%LszMCWhitebox.test_internal_use_of_overridden_methods.<locals>.X.as_integer_ratiocSs|S)Nr)r{rrrr,NszDCWhitebox.test_internal_use_of_overridden_methods.<locals>.X.__abs__N)r�r�r�r%r,rrrr�XKsr�c@seZdZdd�ZdS)z<CWhitebox.test_internal_use_of_overridden_methods.<locals>.YcSs
dgdS)Nr�rr)r{rrrr,RszDCWhitebox.test_internal_use_of_overridden_methods.<locals>.Y.__abs__N)r�r�r�r,rrrr�YQsr�c@seZdZdd�ZdS)z<CWhitebox.test_internal_use_of_overridden_methods.<locals>.IcSs
dgdS)Nr�rr)r{rrr�
bit_lengthVszGCWhitebox.test_internal_use_of_overridden_methods.<locals>.I.bit_lengthN)r�r�r�r�rrrr�IUsr�cs eZdZ�fdd�Zdd�ZdS)z<CWhitebox.test_internal_use_of_overridden_methods.<locals>.Zcs�d��d�fS)Nr�r)r{)r�rrr%ZszMCWhitebox.test_internal_use_of_overridden_methods.<locals>.Z.as_integer_ratiocSs|S)Nr)r{rrrr,\szDCWhitebox.test_internal_use_of_overridden_methods.<locals>.Z.__abs__N)r�r�r�r%r,r)r�rr�ZYsr�gfffffFY@)r`r�rr�r�rQ)r{r�r�r�r�rr)r�r�'test_internal_use_of_overridden_methodsGsz1CWhitebox.test_internal_use_of_overridden_methodsN)r�r�r�rZr[r\r]rerfrVrhrirjrkrmrnrorrrsrwrzr{r~r�r�rrrrrW�s,e+&	;,%0rWztest requires C versionc@seZdZdd�Zdd�ZdS)�
SignatureTestc
Cs�x�tt�D]�}|jd�rq
tt|�}tt|�}|dksH|dksHtj|�r
tj|�}tj|�}t|j	j
��}dd�|j	j
�D�}|j||d|d�dd�|j	j�D�}d	d�|j	j
�D�}	|d
kr
|j||	d|d�q
WdS)NrNr�r cSsg|]}|jd�s|�qS)rN)r�)rr�rrrr�usz5SignatureTest.test_inspect_module.<locals>.<listcomp>zparameter name mismatch in %s)�msgcSsg|]
}|j�qSr)�kind)rr�rrrr�{scSs$g|]}|djd�s|dj�qS)rrNr�)r�r�)rr�rrrr�|sr%zparameter kind mismatch in %s)r�r�r�rr`�inspect�
isfunction�	signaturer��
parametersrpr�rur9)
r{r�p_func�c_func�p_sig�c_sig�c_names�p_names�c_kind�p_kindrrr�test_inspect_modulehs$





z!SignatureTest.test_inspect_modulecstjj�tjj�ttjd�tjd�tjd�tjd�tjd�tjd�tjd�tjd�tjd�tjd�ddtjtj�d�ttjd�tjd�tjd�tjd�tjd�tjd�tjd�ddtjtj�d�i����fdd��dd	�������fd
d�}|d�|d
�dS)Nr�rg�?)rGr\r�r�r6rr�r�r�r��numr�rr)rGr\rr�r�r�r�r�r�rrcstg}i}xb|jj�D]T\}}|dkr&q|j�krD|j�||�q|j�kr`�||||<qtd��qW||fS)Nr{zunexpected parameter kind)r�r9r�r�r	)�moduler�r��kwargs�nameZparam)�POS�POS_KWD�pdictrr�mkargs�s

z0SignatureTest.test_inspect_types.<locals>.mkargscSs(|dkrdS|dkrdS|dkr$dS|S)Nr�rr�r�r6r�r)rrrr�tr�sz,SignatureTest.test_inspect_types.<locals>.trc s�tt|�}tt|�}�x�t|�D�]�}|jd�r2q t||�}t||�}tj|�r tj|�}tj|�}t|j	j
��}�fdd�|j	j
�D�}	�j|	|d|d�dd�|j	j�D�}
dd�|j	j�D�}�j
|
d���j
|d��|d	k�r�j|d
d�|
d
d�d|d�n�jt|�t|
�d|d��t|�\}}
yt|d�|�||
�Wn6tk
�r�}ztd
|||
f��WYdd}~XnX�t|�\}}
yt|d�|�||
�Wq tk
�r�}ztd
|||
f��WYdd}~Xq Xq WdS)NrNcsg|]}�|��qSrr)rr�)r�rrr��szBSignatureTest.test_inspect_types.<locals>.doit.<locals>.<listcomp>zparameter name mismatch in %s)r�cSsg|]
}|j�qSr)r�)rr�rrrr��scSsg|]
}|j�qSr)r�)rr�rrrr��srr�r�zparameter kind mismatch in %srzinvalid signature for %s: %s %s)rr�r`r�r�r�r�r�r�r�rpr�rurr�r�r	)ZtyZp_typeZc_typerr�r�r�r�r�r�r�r�r��kwds�err)r�r�r�r{r�rrr��sB








$z.SignatureTest.test_inspect_types.<locals>.doitr�r )	r�Z_ParameterKindZPOSITIONAL_ONLYZPOSITIONAL_OR_KEYWORDr`r�rmr2r�)r{r�r)r�r�r�r�r{r�r�test_inspect_types�s@



/z SignatureTest.test_inspect_typesN)r�r�r�r�r�rrrrr�csr�r�r�cCsvtt�tt�|dk	r|ntd�a|a|dkr6t}nttg}xzt	j
t�D]l}d|ksJ|jd�rbqJ|j
d�\}}|dk	r�||kr�qJ|fdd�}ttd||�ttd||�~~~~qJWzht|�|dk�r ddlm}	tjd}
t�rttjd<tt||	d	�ttjd<tt|�|
tjd<Wdt�r8tjtt�tjtt�t�sXtjd
t�ttjdk	�rptd��XdS)Nrz.decTestrRcSs|jt|�S)N)r��	directory)r{r�rrrr�#sztest_main.<locals>.<lambda>Ztest_r)�IGNORE_EXCEPTION_DETAIL)Zoptionflagsz*C tests skipped: no module named _decimal.zGInternal error: unbalanced number of changes to sys.modules['decimal'].)r'r`r�rr�r��	all_testsr�r��os�listdirr�r�r�rjrZdoctestr�rDrErr%�ORIGINAL_CONTEXT�warnings�warn�UserWarning�orig_sys_decimalr	)�arith�verbose�
todo_tests�debugZtest_classes�filename�head�tailZtesterr�rIrrr�	test_mainsH




r�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)r�r�)r�r�r�r�)NNNN)�r�r�rDrxr�rBrTr�r?rWZtest.supportrrrrrrrr	r
rr�Ztimer�r�rXr`r�rEr�Z
cfractionsZ
pfractionsr
r&r2r�rpr$rqrvrtrwrxrursrrrbr�rrnrjrirkrmrlr!rorir�r'ZTESTDATADIRr��argvr��__file__�path�dirname�curdirZtestdir�sepr��isdirr�r��hasattrZEXTRA_FUNCTIONALITYZ
skipUnlessrVZskipIfZskip_if_extra_functionalityZTestCaser*r�r�r�r=r>r?rlrmrnrcrdrer�r�r�r�r�r�r�r�r;r<r=rfrgrhr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr#r8rWr�r��insertr�ZoptparseZOptionParserrrZ
add_option�
parse_args�optr��skipr�rrrr�<module>sp




0

eWM)',,/Xm~
P>m
Ua	
7



Youez - 2016 - github.com/yon3zu
LinuXploit