Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_long.cpython-311.pyc
�

�Ke����ddlZddlmZddlZddlZddlZddlZejjZ	de	zZ
e
dz
ZdZdZ
ddde
e
dz	ddgZd	Zede	z��D]Ze�edz
��edzZ� [ed
�eD��d�eD��zz
ZejjZejjZejjZejjZdezdeez
dz
zz
Zd�Zd
�ZGd�dej��Z e!dkrej"��dSdS)�N)�support���F�lUU�*UU�*l�*UU�*UU
�c��g|]}|��S�r
��.0�xs  �8/usr/local/apps/python3/lib/python3.11/test/test_long.py�
<listcomp>rs�� � � �1�Q�B� � � �c��g|]}|��Sr
r
rs  rrrs��#8�#8�#8�1�Q�B�#8�#8�#8rc�>�tjjdz}tjj|z
}d|z}gd�}|dkrdS|dkrt	|��S|���|z
}|dkr||zn||z	t
|d|zz��z}|||dzz
}|||kz|krtd���|d	zdkr|d	zdtjjzksJ�|d|zztjjksJ�tj
t|��|��S)
z9
    Correctly-rounded integer-to-float conversion.

    rr)r������rrrrrr�r�z%integer too large to convert to floatr)�sys�
float_info�mant_dig�max_exp�int_to_float�
bit_length�bool�
OverflowError�max�math�ldexp�float)�n�	PRECISION�	SHIFT_MAX�Q_MAX�ROUND_HALF_TO_EVEN_CORRECTION�shift�qs       rrr'sJ����'�!�+�I���&��2�I�
��N�E�$?�$?�$?�!�	�A�v�v��s�	
�Q����a�R� � � � �
�L�L�N�N�Y�&�E��q�y�y��e�V���q�E�z�T�!��e��n�:L�5M�5M�&M�A��	&�q�1�u�	-�-�A�
��U�
��i�'�'��C�D�D�D�
�q�5�A�:�:�!�q�&�A���(?�$@�@�@�@�@��q�%�x�<�3�>�-�-�-�-�-��:�e�A�h�h��&�&�&rc�x�||zdk}t|��t|��}}|std���|t|zkrtd���|���|���z
}|dkr|d|z|zks|dkr|d|zz|kr|dz
}t|t��tz
}|t|d��z|t|d��z}}t||��\}}d|z|ksd|z|kr|dzdkr|dz
}tj
||��}|r|n|S)z-Correctly-rounded true division for integers.rzdivision by zeroz)int/int too large to represent as a floatrr)�abs�ZeroDivisionError�DBL_MIN_OVERFLOWrrr�DBL_MIN_EXP�DBL_MANT_DIG�divmodr r!)�a�b�negative�d�expr)�r�results        r�truedivr8UsS����s�Q�w�H��q�6�6�3�q�6�6�q�A�
�4�� 2�3�3�3���q� � � ��G�H�H�H�	
����������'�A��A�v�v�!�q�!�t�a�x�-�-�1�q�5�5�Q��Q�B��Y�!�^�^�	�Q����a��
�
��
,�C���S�D�!����a�3�s�A�;�;�.�q�A��!�Q�<�<�D�A�q�	��s�Q�w�w�!�A�#��(�(�q�1�u��z�z�	�Q���
�Z��3�
�
�F��*�F�7�7�F�*rc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zejd���Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd=d�Zejd���Zd�Zd�Z ej!d���Z"ej!ej#e$j%dzd d!�"��d#�����Z&d$�Z'ej!ej#e$j%d%zd&d!�"��d'�����Z(d(�Z)d)�Z*d*�Z+d+�Z,d,�Z-d-�Z.ej!d.���Z/ej!d/���Z0ej!d0���Z1d1�Z2d2�Z3d3�Z4d4�Z5d5�Z6d6�Z7ej!d7���Z8d8�Z9d9�Z:d:�Z;d;�Z<d<S)>�LongTestc�f�|�|d��|tz}|tz
dz}d}d}ttj��tdzz��dz}||kr�|dz	dz}t	|||z
��}|�d|cxko
tknc��||z}||z}|dzr|d|zdz
z}ttj��tdzz��}||k��|�||cxko|knc��tj��dkr|}|S)Nrrr��?)�
assertGreater�SHIFT�int�random�min�
assertTrue)�self�ndigits�nbits_hi�nbits_lo�answer�nbitsr6�bitss        r�getranzLongTest.getran{s[�����7�A�&�&�&��U�?���e�#�a�'��������
���5�1�9�-�.�.��2���h�����F�a�<�D��t�X��-�.�.�D��O�O�A��.�.�.�.��.�.�.�.�/�/�/��D�L�E��t�^�F��1�u�
4��A��I��?�3���F�M�O�O�u�q�y�1�2�2�A��h���	
����E�5�5�5�5�X�5�5�5�5�6�6�6��=�?�?�S� � ��W�F��
rc��d}t|��D]'}|tztjdt��z}�(tj��dkr|}|S)Nrr<)�ranger>r@�randint�MASK)rDrG�is   r�getran2zLongTest.getran2�sW�����w���	A�	A�A���o����4�)@�)@�@�F�F��=�?�?�S� � ��W�F��
rc���|j}|�||���5t||��\}}||z||z}}||z||z}	}|||	d��|||d��|||d��||||z|zd��|dkr%|�d|cxko|kncd��n$|�||cxkodkncd��ddd��dS#1swxYwYdS)N�r
�yzmultiplication does not commutez(divmod returns different quotient than /z#divmod returns different mod than %zx != q*y + r after divmodrzbad mod from divmod)�assertEqual�subTestr0rB)
rCr
rS�eqr)r6�q2�r2�pab�pbas
          r�check_divisionzLongTest.check_division�s���
�
��
�\�\�A��\�
#�
#�	C�	C��!�Q�<�<�D�A�q���T�1�Q�3��B���s�A�a�C��C��B�s�C�:�;�;�;��B�q�"�@�A�A�A��B�q�"�;�<�<�<��B�q�!�A�#��'�6�7�7�7��1�u�u�����Q�
�
�
�
��
�
�
�
�,A�B�B�B�B�����A�
�
�
�
��
�
�
�
�,A�B�B�B�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C�	C�	Cs�B1C�C!�$C!c��ttdtdz����ttttdz����z}|�tdz��|D]I}|�|��}|D]/}|�|��pd}|�||���0�J|�dd��|�dd��|�dd	��|�d
d��|�dd
��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��dS)Nr��l!Us/w��3alZW��3al+Q@{�d��B]Ol�Nl�O�Ol�Nl�t�e�o%g�q�Cgx<l�&�ghrsGlQ5��K�4+�o�-bklC�4+�o�-bkl��.#w�flD�&I-�Xl�Z��nSu9bl�c�v��
��<�Ilrd�FBu�'�pl�PhbIi|�$l1�m�{Wqi���8l�s~5^Fi�y�+l'H�
<{�Cl`<{�Cl�ED_5(�Nl�o�ybal=2zz6l�9�t�m)�listrL�	MAXDIGITS�KARATSUBA_CUTOFF�appendrJr[)rC�digits�lenxr
�lenyrSs      r�
test_divisionzLongTest.test_division�s���e�A�y��{�+�+�,�,�t�E�:J�6F��6K�5M�5M�0N�0N�N���
�
�&��*�+�+�+��	*�	*�D����D�!�!�A��
*�
*���K�K��%�%�*����#�#�A�q�)�)�)�)�
*�	
���8�/�	1�	1�	1����@�)�	+�	+�	+����@�)�	+�	+�	+����A�3�	5�	5�	5�	
���@�2�	4�	4�	4����@�3�	5�	5�	5�	
���N�I�6�6�6����/��;�;�;����.�	�:�:�:����.��?�?�?����.��?�?�?����,�n�=�=�=�=�=rc��ttdd����ttttdz����z}|�tdztdzg��d�|D��}|D]}d|zdz
}|D]r}||kr�	|�||���5d|zdz
}||z}d||zzd|zz
d|zz
dz}|�||��ddd��n#1swxYwY�s��dS)Nr��
�dc�"�g|]}|tz��
Sr
)r>)r�digits  rrz+LongTest.test_karatsuba.<locals>.<listcomp>�s��2�2�2�%���
�2�2�2r)�abits�bbits)r_rLra�extendrUrT)	rCrcrIrmr1rnr2r
rSs	         r�test_karatsubazLongTest.test_karatsuba�s����e�A�q�k�k�"�"�T�%�0@�0@�2�0E�+G�+G�&H�&H�H���
�
�'�"�,�.>��.D�E�F�F�F�2�2�6�2�2�2���	+�	+�E��e��q� �A��

+�

+���5�=�=���\�\��U�\�;�;�+�+��e��q�(�A��A��A����
�.��u�*�&��u�*�&���A��$�$�Q��*�*�*�+�+�+�+�+�+�+�+�+�+�+����+�+�+�+��

+�	+�	+s�*;C1�1C5�8C5c��|j}|�|���5||dzd��||dz|��||dz|��||dz|��||dzd��||dz|��|||��|||z|��|||z|��|||zd��|||zd��|||zd��|||zd��||d|z��|||dz
��ddd��n#1swxYwYtdtz��D]�}d|z}|�|||���5|||z|z	|��|||z||z	��|||z||z��|||z||z	|z��|||z||dz
z��ddd��n#1swxYwY��dS)N)r
rrrr)r
r#�p2)rTrUrLr>)rCr
rVr#rrs     r�check_bitop_identities_1z!LongTest.check_bitop_identities_1�s���
�
��
�\�\�A�\�
�
�	�	��B�q�1�u�a�L�L�L��B�q�1�u�a�L�L�L��B�q�1�u�a�L�L�L��B�q�2�v�q�M�M�M��B�q�2�v�r�N�N�N��B�q�2�v��r�N�N�N��B�q�A�2�#�J�J�J��B�q�1�u�a�L�L�L��B�q�1�u�a�L�L�L��B�q�1�u�a�L�L�L��B�q�A�2�v�q�M�M�M��B�q�A�2�v�r�N�N�N��B�q�A�2�v�r�N�N�N��B��r�1��r�6�N�N�N��B��r�Q�q�S�6�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	� �q��w���	+�	+�A��a��B�����Q�2��.�.�
+�
+���1��6�Q�;��"�"�"���1��7�A��F�#�#�#���1�r�6�1��6�"�"�"���1��s�7�A��F�a�K�(�(�(���1��s�7�A�"�q�&�	�M�*�*�*�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+����
+�
+�
+�
+��	+�	+s%�C)D�D�D�A$G�G	�G	c���|j}|�||���5|||z||z��|||z||z��|||z||z��|||z|z|��|||z||z��|||z||z��|||z||z||zz��|||z||z||zz��|||z||z||zz��ddd��dS#1swxYwYdS)NrR�rTrU)rCr
rSrVs    r�check_bitop_identities_2z!LongTest.check_bitop_identities_2s���
�
��
�\�\�A��\�
#�
#�		+�		+��B�q�1�u�a�!�e�����B�q�1�u�a�!�e�����B�q�1�u�a�!�e�����B�q�1�u�q�y�!�����B�q�1�u���a�R��j�!�!�!��B�q�1�u���a�R��j�!�!�!��B�q�1�u�q�1�u�!�a�%��(�)�)�)��B�q�1�u�q�A�2�v�1�"�q�&�)�*�*�*��B�q�1�u�q�1�u�!��q�b��)�*�*�*�		+�		+�		+�		+�		+�		+�		+�		+�		+�		+�		+�		+����		+�		+�		+�		+�		+�		+s�CC,�,C0�3C0c�r�|j}|�|||���5|||z|z|||zz��|||z|z|||zz��|||z|z|||zz��||||zz||z||zz��||||zz||z||zz��ddd��dS#1swxYwYdS)N)r
rS�zru)rCr
rSrxrVs     r�check_bitop_identities_3z!LongTest.check_bitop_identities_3s:��
�
��
�\�\�A��a�\�
(�
(�	/�	/��B��A���{�A��Q��K�(�(�(��B��A���{�A��Q��K�(�(�(��B��A���{�A��Q��K�(�(�(��B�q�A��E�{�Q��U�q�1�u�-�.�.�.��B�q�A��E�{�Q��U�q�1�u�-�.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/s�A?B,�,B0�3B0c
��tD]}|�|���tdtdz��}|D]�}|�|��}|�|��|D]]}|�|��}|�||��|�|||�||zdz�����^��dS)Nrr)�specialrsrLr`rJrvry)rCr
rcrdrerSs      r�test_bitop_identitieszLongTest.test_bitop_identitiess����	-�	-�A��)�)�!�,�,�,�,��q�)�A�+�&�&���	S�	S�D����D�!�!�A��)�)�!�,�,�,��
S�
S���K�K��%�%���-�-�a��3�3�3��-�-�a��D�K�K����q�@P�4Q�4Q�R�R�R�R�
S�	S�	Src�4�g}d}|dkrd|}}|r7t||��\}}|�t|����|�7|���|pdg}dd|�ddddd�|zd�d	�|D����zS)
Nrr�-�0b�0o��0x)r�ri�c3�&K�|]}d|V��
dS)�0123456789abcdefNr
)rrOs  r�	<genexpr>z'LongTest.slow_format.<locals>.<genexpr>1s(����=�=��)�!�,�=�=�=�=�=�=r)r0rbr?�reverse�join)rCr
�baserc�signr6s      r�slow_formatzLongTest.slow_format%s��������q�5�5��!��!�D��	"��!�T�?�?�D�A�q��M�M�#�a�&�&�!�!�!��	"�	��������A�3���5�D�5�z��D�b�d�3�3�D�9�:��w�w�=�=�f�=�=�=�=�=�>�	>rc���dtfdtfdtfdtfdtffD]�\}}||��}|�||j���5|�||��}|�||��ddd��n#1swxYwY|�|���5|�t|d��|��ddd��n#1swxYwY��dS)Nrr�rir�)r
�mapper)�gotr)
�bin�oct�str�repr�hexrU�__name__r�rTr?)rCr
r�r�r��expecteds      r�check_format_1zLongTest.check_format_13sm����H�q�#�h��S�	�B��:��C�y�P�	1�	1�L�D�&��&��)�)�C�����&�/��:�:�
0�
0��+�+�A�t�4�4��� � ��h�/�/�/�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0����#��&�&�
1�
1�� � ��S�!���a�0�0�0�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1��	1�	1s$�-B�B	�B	�1%C"�"C&	�)C&	c���tD]}|�|���td��D]G}tdtdz��D],}|�|��}|�|���-�HdS)Nrir)r{r�rLr`rJ)rCr
rOrds    r�test_formatzLongTest.test_format<s����	#�	#�A�����"�"�"�"��r���	'�	'�A��a��1��-�-�
'�
'���K�K��%�%���#�#�A�&�&�&�&�
'�	'�	'rc��ddddzfg}|D]_\}}dD]W}dD]R}||z|z}|}|dkr|tur|}	|�t|��|���C#t$rY�OwxYw�X�`|�ttd��|�ttd	��|�ttd
��|�ttd��|�ttdd
��|�ttdd��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�td d��d��|�ttd!d��|�ttd"d��d#d$d%d&d'd(d)d*d+d,dzd,dzg}|D]$}	|�ttd-|	���%|�ttd.��dS)/N)�100000000000000000000l F�x:^V�e10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000rirj)r��+r~)r�� �	z  		  r~�123L�123l�0Lz-37L�0x32Lr��1L���+�000r�0o123�S�0x123i#�0b100rz	 0O123   z 0X123  z 0B100 �0z+0z-0�00�08z-012395is������i�l����������l����l����r�42uこんにちは)�
ValueErrorrTr?�assertRaises)
rC�LL�s�vr��prefix�ss�vv�
invalid_basesr�s
          r�	test_longzLongTest.test_longDs~��'���C��(�
���
	�
	�D�A�q�$�	
�	
��7���F��$���*�B��B��s�{�{�q�
�':�':��R����(�(��R���"�5�5�5�5��%�����������	
�	
���*�c�6�2�2�2����*�c�6�2�2�2����*�c�4�0�0�0����*�c�6�2�2�2����*�c�7�B�7�7�7����*�c�4��4�4�4�����T�2����+�+�+�	
����U�A����*�*�*�����W�a���"�-�-�-�����W�a���#�.�.�.�����W�a���!�,�,�,�����[�!�,�,�b�1�1�1�����Z��+�+�S�1�1�1�����Y��*�*�A�.�.�.�����S�!���a�(�(�(�����T�1���q�)�)�)�����T�1���q�)�)�)�����T�1���q�)�)�)����*�c�4��3�3�3����*�c�9�a�8�8�8��!�5�&�(�!�5�&�(��S�&�1�c�6�'��
�
"�	;�	;�D����j�#�t�T�:�:�:�:�	
���*�c�+K�L�L�L�L�Ls�#A�
A'	�&A'	c�H�Gd�d��}|�tt|����Gd�d��}|�t��5|�t|����d��ddd��dS#1swxYwYdS)Nc��eZdZd�ZdS)�*LongTest.test_conversion.<locals>.JustLongc��dS�N�*r
�rCs r�__long__z3LongTest.test_conversion.<locals>.JustLong.__long__�����rrN)r��
__module__�__qualname__r�r
rr�JustLongr�s#������
�
�
�
�
rr�c��eZdZd�Zd�ZdS)�+LongTest.test_conversion.<locals>.LongTruncc��dSr�r
r�s rr�z4LongTest.test_conversion.<locals>.LongTrunc.__long__�r�rc��dS)N�r
r�s r�	__trunc__z5LongTest.test_conversion.<locals>.LongTrunc.__trunc__�s���trN)r�r�r�r�r�r
rr�	LongTruncr��s2������
�
�
�
�
�
�
�
rr�r�)r��	TypeErrorr?�assertWarns�DeprecationWarningrT)rCr�r�s   r�test_conversionzLongTest.test_conversion}s��	�	�	�	�	�	�	�	�	
���)�S�(�(�*�*�5�5�5�	�	�	�	�	�	�	�	��
�
�0�
1�
1�	5�	5����S�����-�-�t�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	5�	5s�,B�B�Bc���	t|��}n#t$rd}YnwxYw	t|��}n#t$rd}YnwxYwd�|||��}|�|||��dS)N�overflowzAError in conversion of integer {} to float.  Got {}, expected {}.)r"rr�formatrT)rCr#�actualr��msgs     r�check_float_conversionzLongTest.check_float_conversion�s���	 ��1�X�X�F�F���	 �	 �	 ��F�F�F�	 ����	"�#�A���H�H���	"�	"�	"�!�H�H�H�	"����&�&,�f�Q���&A�&A�	������3�/�/�/�/�/s��!�!�5�A�Ac
��gd�}|D]J}|�t|��|��|�t|��|���KdD]Y\}}td��D]D}|�ttd|zd|zz����d|zd|zz���E�ZdD]Y\}}td��D]D}|�ttd|zd|zz����d|zd|zz���E�Ztt��}dt
z}||zdz}|�t|��t��|�t|dz��t��|�t|dz
��t��|�tt|��|�td|z
��t��|�tt|��|�tt|dz
��|�tt|��|�tt|dz��|�ttd|zdz
��|�ttd|z��|�tt||z��td	��D]�}d|zd
zdz}d|zdz}|�tt|����|��d|zd
z}d|zdz}|�tt|����|����|dz
||dz|dz
||dz|dz
||dzd|zdz
d|z||zg}|�|��tdd
��D]3}tdd��D] }|�	d|dzz|z���!�4|D]-}	|�
|	��|�
|	���.dS)N)rrrl����l����l������l����l�����l)�rr)rr�r^r�rr�rhr)�r��rr�rrr�))rrr�)rrr�r�r�)r�r�r�)r�r�)�	r�)rir�)��)r�r�)�
r�)r]r�)rr�r�rrjlr����r������5)rTr"rLr?�DBL_MAX�DBL_MAX_EXPr�rrorbr�)
rC�exact_valuesr
rS�p�int_dbl_max�	top_power�halfway�test_values�values
          r�test_float_conversionzLongTest.test_float_conversion�sp��	"�	"�	"���	,�	,�A����U�1�X�X�q�)�)�)����U�A�2�Y�Y���+�+�+�+�M�	M�	M�D�A�q��2�Y�Y�
M�
M��� � ��U�1�a�4��q��>�%:�%:�!;�!;�Q��T�5��7�^�L�L�L�L�
M�3�	M�	M�D�A�q��2�Y�Y�
M�
M��� � ��U�1�a�4��q��>�%:�%:�!;�!;�Q��T�5��7�^�L�L�L�L�
M��'�l�l���{�N�	���*�Q�.������{�+�+�W�5�5�5�����{�1�}�-�-�w�7�7�7�����w�q�y�)�)�7�3�3�3����-���8�8�8�����q��y�)�)�G�8�4�4�4����-����9�9�9����-��	�!��<�<�<����-��	�:�:�:����-��	�!��<�<�<����-���)��A�
�>�>�>����-���)��<�<�<����-��	�)�0C�D�D�D��s���	/�	/�A��1��	�"�Q�&�A��1��	�"�A����S��q���]�]�A�.�.�.��1��	�"�A��1��u��A����S��q���]�]�A�.�.�.�.�

��M�;��A�
��A�I�w��!���a�K��I�a�K�
�i�K��M�1�Y�;�	�)�(;�	
��	���<�(�(�(��r�1���	2�	2�A��4��%�%�
2�
2���"�"�1�q��t�9�q�=�1�1�1�1�
2� �	0�	0�E��'�'��.�.�.��'�'���/�/�/�/�	0�	0rc�L�dD]2}|�tt|����|���3d}ddz}|}|||td�}dD]$}|�t
t||���%|�t|��t|��d��dS)N)g���r��?�@�X123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345ri0u)�huge�mhuge�shuger )$�float(huge)�float(mhuge)z
complex(huge)zcomplex(mhuge)zcomplex(huge, 1)zcomplex(mhuge, 1)zcomplex(1, huge)zcomplex(1, mhuge)z	1. + hugez	huge + 1.z
1. + mhugez
mhuge + 1.z	1. - hugez	huge - 1.z
1. - mhugez
mhuge - 1.z	1. * hugez	huge * 1.z
1. * mhugez
mhuge * 1.z
1. // hugez
huge // 1.z1. // mhugezmhuge // 1.z	1. / hugez	huge / 1.z
1. / mhugez
mhuge / 1.z
1. ** hugez
huge ** 1.z1. ** mhugezmhuge ** 1.zmath.sin(huge)zmath.sin(mhuge)zmath.sqrt(huge)zmath.sqrt(mhuge)z(float(shuge) should not equal int(shuge))rTr"r?r r�r�eval�assertNotEqual)rCr
r�r�r��	namespace�tests       r�test_float_overflowzLongTest.test_float_overflow�s���*�	/�	/�A����U�3�q�6�6�]�]�A�.�.�.�.����E�z�����!�E�E�4�P�P�	��	D�	D�D� 
���m�T�4��C�C�C�C�	
���E�%�L�L�#�e�*�*�6�	8�	8�	8�	8�	8rc��tjtj��}tt	d����gd�zD]`}d|z}tj|��}|�||��||z}tj|��}|�||���addzddfD]N}|�ttj|��|�ttj|���OdS)Nri)rj���'rr	rr)	r �log10�er_rL�assertAlmostEqual�logr�r�)rC�LOG10Er5r�r
r�r
�bads        r�	test_logszLongTest.test_logss�����D�F�#�#����b�	�	�?�?�%7�%7�%7�7�		2�		2�C��#�I�E��J�u�%�%�E��"�"�5�#�.�.�.��V�|�H��(�5�/�/�C��"�"�3��1�1�1�1��%�Z�=�"�a�'�	;�	;�C����j�$�(�C�8�8�8����j�$�*�c�:�:�:�:�	;�	;rc���
�|j}G�
fd�d���
gd�}dD]X}|�|dz
|dz
||dz|dzt|dz
��t|��t|dz��g���Y|�ddd	tjttj��g��td
��}|�ddd	ddz|dz
||dzg��|�d�|D����|D]�}�
|��}|D]�}�
|��}||k||kz
}|�|||�
��5||k||kz
}	|||	��|||k|dk��|||k|dk��|||k|dk��|||k|dk��|||k|dk��|||k|dk��ddd��n#1swxYwY�܌�dS)Nc�>��eZdZd�Z�fd�Zd�Zd�Zd�Zd�Zd�Z	dS)	�)LongTest.test_mixed_compares.<locals>.Ratc�l�t|t��r||_d|_dSt|t��r�tjt|����\}}|dksd|cxkrdksnJ�d}d}|rTtj||��}t|��}||z	dksJ�||z|z}||z}d|cxkrdksnJ�||z}|�T|dkr||z}d}n|}d|z}|dkr|}||_||_t	|��t	|��z|ksJ�dStd|z���)Nrrr<r��rzcan't deal with %r)
�
isinstancer?r#r4r"r �frexpr+r!r�)	rCr��fr�CHUNK�toprlr#r4s	         r�__init__z2LongTest.test_mixed_compares.<locals>.Rat.__init__s����e�S�)�)�%B�"�D�F��D�F�F�F���u�-�-�"B��:�c�%�j�j�1�1�D�A�q���6�6�S�A�^�^�^�^��^�^�^�^�^�^��E��C��#� �J�q�%�0�0�� #�A����$��~��2�2�2�2�"�e�|�u�4���U�
��"�a�~�~�~�~�#�~�~�~�~�~�~��U�
���#��A�v�v��1�H��������!��G���q�y�y��B���D�F��D�F� ��8�8�e�A�h�h�.�%�7�7�7�7�7�7�#�$8�5�$@�A�A�Arc���t|���s�|��}|j|jz|j|jz}}||k||kz
S)N)rr#r4)rC�otherr
rS�Rats    �r�_cmp__z0LongTest.test_mixed_compares.<locals>.Rat._cmp__GsP���!�%��-�-�'��C��J�J�E��v���'���%�'�)9�1���A��!�a�%�(�(rc�4�|�|��dkS�Nr�r�rCrs  r�__eq__z0LongTest.test_mixed_compares.<locals>.Rat.__eq__L����{�{�5�)�)�Q�.�.rc�4�|�|��dkSr!r"r#s  r�__ge__z0LongTest.test_mixed_compares.<locals>.Rat.__ge__Nr%rc�4�|�|��dkSr!r"r#s  r�__gt__z0LongTest.test_mixed_compares.<locals>.Rat.__gt__P����{�{�5�)�)�A�-�-rc�4�|�|��dkSr!r"r#s  r�__le__z0LongTest.test_mixed_compares.<locals>.Rat.__le__Rr%rc�4�|�|��dkSr!r"r#s  r�__lt__z0LongTest.test_mixed_compares.<locals>.Rat.__lt__Tr*rN)
r�r�r�rrr$r'r)r,r.)rs�rrrs��������&
B�&
B�&
B�P
)�
)�
)�
)�
)�

/�
/�
/�
/�
/�
/�
.�
.�
.�
/�
/�
/�
.�
.�
.�
.�
.rr)rg����MbP?g�G�z��?r�g�?g@��x�D�Zb���ti)g�BgCg@Cr�g333333�?rrrr/i Nc��g|]}|��Sr
r
rs  rrz0LongTest.test_mixed_compares.<locals>.<listcomp>bs��(�(�(�Q�q�b�(�(�(r)r
rS�Rcmp)rTror?r�maxsizer"rU)rCrV�cases�tr
�RxrS�Ryr1�xycmprs          @r�test_mixed_compareszLongTest.test_mixed_comparess����
�
��7	.�7	.�7	.�7	.�7	.�7	.�7	.�7	.�7	.�7	.�r8�7�7��+�	7�	7�A��L�L�!�c�'�1�s�7�A�q�3�w��C���a��c�(�(�C��F�F�C��!��H�H�6�
7�
7�
7�
7�
���a��A�s�{�E�#�+�,>�,>�?�@�@�@�
��J�J��
���a��A�q�E�z�1�Q�3��1�Q�3�7�8�8�8�
���(�(�%�(�(�(�)�)�)��
	*�
	*�A���Q���B��
*�
*���S��V�V���R��B��G�,���\�\�A���\�6�6�*�*���U�q�1�u�-�E��B�t�U�O�O�O��B�q�A�v�t�q�y�)�)�)��B�q�A�v�t�q�y�)�)�)��B�q�1�u�d�Q�h�'�'�'��B�q�A�v�t�q�y�)�)�)��B�q�1�u�d�Q�h�'�'�'��B�q�A�v�t�q�y�)�)�)�*�*�*�*�*�*�*�*�*�*�*����*�*�*�*��
*�
	*�
	*s�BG&�&G*�-G*c
�z�|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd	��d
��|�tdd	��d��|�tdd
��d��|�tdd
��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�td d��d
��|�td d��d
��|�ttd!d"��d��d!��|�ttd!d"��d��d#��|�ttd!d"��d��d$��|�ttd!d"��d��d%��|�ttd&d'��|�td&d(��d)��|�td&d*��d+��|�tdd,��d��|�td d,��d
��|�tdd,��d-��|�tdd,��d.��|�tdd/��d-��|�tdd/��d.��|�tdd0��d1��|�tdd0��d.��|�tdd2��d3��|�tdd2��d.��|�ttd&d4��|�td&d5��d6��|�tdd7��d8��|�td d7��d9��|�tdd7��d:��|�tdd7��d;��|�tdd<��d:��|�tdd<��d;��|�tdd=��d>��|�tdd=��d;��|�tdd?��d@��|�tdd?��d;��|�ttd&dA��|�tdBdC��dD��|�ttddE��|�ttddF��|�ttddG��|�ttddH��|�tdItddJ��|�tdItddK��|�tdItddL��|�tdItddM��|�tdNtddO��|�tdPtddQ��dR�t
tdS��tdT��dz��D��dU�t
tdV��tdW��dz��D��zD]�}|dXvr�|�ttdY|��|�ttd|��|�ttd|��|�ttdZd[z|��|�ttdZd[z|����d\D]F}d]D]A}|�t||��tt|��|�����B�GdS)^Ni�[r4�	123456789�,z123,456,789�_�123_456_789rr~�1rz-1z-3z  1z -1z+3z +1z 3r�z 1r^r
�3�Xi��4d2i.���z-4d2�8xz     4d2z    -4d2����ber��BEz-bez-BE���Iz,x�_x�	4996_02d2�_X�	4996_02D2�o�2322z-2322z-oz oz 2322z+oz+2322z,o�_o�
111_4540_1322r2�11z-11�10011010010z-10011010010z-bz bz 10011010010z+bz+10011010010z,b�90�_b�11_0000_0011_1001z1.3�_cz,cz+czCannot specify bothz_,z,_z_,dz,_dzCannot specify ',' with 's'z,szCannot specify '_' with 's'�_sc�,�g|]}t|����Sr
��chrrs  rrz+LongTest.test__format__.<locals>.<listcomp>����I�I�I��S��V�V�I�I�Irr1rxc�,�g|]}t|����Sr
rWrs  rrz+LongTest.test__format__.<locals>.<listcomp>�rYr�A�ZzbcdoxXeEfFgGn%rrrjzeEfFgG%)rrrrj���rFi.�i�)	rTr�r?r�r��assertRaisesRegexrL�ordr")rC�format_specr�s   r�test__format__zLongTest.test__format__rsy	������	�3�/�/��=�=�=�����	�3�/�/��=�=�=�����	�3�/�/��?�?�?�����	�3�/�/��?�?�?�	
�����3����-�-�-������C���$�/�/�/������4���%�0�0�0������D�)�)�5�1�1�1������4���%�0�0�0������D�)�)�5�1�1�1������4���%�0�0�0������D�)�)�5�1�1�1������3����.�.�.������C���$�/�/�/�	
�����3����-�-�-������3����-�-�-������c�*�*�E�2�2�2������s�+�+�V�4�4�4������d�+�+�Z�8�8�8������t�,�,�j�9�9�9������c�*�*�E�2�2�2������s�+�+�V�4�4�4������C���$�/�/�/������C���$�/�/�/������D�"�
�
�s�3�3�T�:�:�:������D�"�
�
�s�3�3�T�:�:�:������T�2�����4�4�e�<�<�<������T�2�����4�4�e�<�<�<����*�f�j�$�?�?�?�����
�D�1�1�;�?�?�?�����
�D�1�1�;�?�?�?�	
�����3����-�-�-������C���$�/�/�/������c�*�*�F�3�3�3������s�+�+�W�5�5�5������d�+�+�V�4�4�4������t�,�,�g�6�6�6������d�+�+�W�5�5�5������t�,�,�g�6�6�6������d�+�+�W�5�5�5������t�,�,�g�6�6�6����*�f�j�$�?�?�?�����
�D�1�1�?�C�C�C�	
�����3����.�.�.������C���%�0�0�0������c�*�*�M�:�:�:������s�+�+�^�<�<�<������d�+�+�]�;�;�;������t�,�,�n�=�=�=������d�+�+�^�<�<�<������t�,�,�n�=�=�=������d�+�+�^�<�<�<������t�,�,�n�=�=�=����*�f�j�$�?�?�?������t�,�,�.A�B�B�B�	
���*�f�a��7�7�7����*�f�a��6�6�6����*�f�a��6�6�6����*�f�a��6�6�6�	
���z�+@�&�!�T�R�R�R����z�+@�&�!�T�R�R�R����z�+@�&�!�U�S�S�S����z�+@�&�!�U�S�S�S����z�+H�&�RS�UY�Z�Z�Z����z�+H�&�RS�UY�Z�Z�Z�J�I�U�3�s�8�8�S��X�X�a�Z�-H�-H�I�I�I�I�I�U�3�s�8�8�S��X�X�a�Z�-H�-H�I�I�I�J�	N�	N�K��"2�2�2��!�!�*�f�a��E�E�E��!�!�*�f�a��E�E�E��!�!�*�f�b�+�F�F�F��!�!�*�f�a��f�k�J�J�J��!�!�*�f��3��i��M�M�M��%�	D�	D�K�G�
D�
D��� � ���{�!;�!;�!'��e���k�!B�!B�D�D�D�D�
D�	D�	Drc��|�tttd����|�tttd����|�tttd����dS)N�infz-inf�nan)r�rr?r"r�r�s r�test_nan_infzLongTest.test_nan_inf�sb�����-��e�E�l�l�;�;�;����-��e�F�m�m�<�<�<����*�c�5��<�<�8�8�8�8�8rc���|�t��5ddz}ddd��n#1swxYwY|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��dS)Nrrr^r���rC�r�r,rT�rCr<s  r�test_mod_divisionzLongTest.test_mod_division�s-��
�
�
�0�
1�
1�	�	��A��A�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
����!�$�$�$�����1�%�%�%�����2�&�&�&�����B�'�'�'������#�#�#�����!�$�$�$�����!�$�$�$�����1�%�%�%�%�%��-�1�1c�*�ddz}|}|�||zd��|�||zd��|�||zd��|�||zd��|�d|zd��|�d|zd��|�d|zd��|�d|zd��|�d|z|dz	z|zd��|�d|z|dz	z|zd��|�d|z|dz	z|zd��|�d|z|dz	z|zd��|�||dzzd	��|�d
|z|zd
��||d�}dD]$}|�tt||���%d
D],}t||��}|�|dd|z���-dD]$}|�tt||���%dS)Nri@�r�r�ri�gԄ@gԄ�r<i@B)r�r�)rrzhuge / 1zhuge / 2z	huge / -1z	huge / -2zmhuge / 100zmhuge / 200)z1 / hugez2 / hugez	-1 / hugez	-2 / hugez100 / mhugez200 / mhugezexpected underflow to 0 from %r)zhuge / 0z	mhuge / 0)rTr�rrr,)rCr�r�rr��	underflowr7�zeros        r�test_true_divisionzLongTest.test_true_division�s����E�z�����������c�*�*�*��������,�,�,�������t�,�,�,�������t�,�,�,�����T��3�'�'�'�����T��3�'�'�'�����U��C�(�(�(�����U��C�(�(�(����#��*���	�2�d�:�E�B�B�B����#��+��!��4��=�u�E�E�E����#��*���	�2�e�;�V�D�D�D����#��+��!��4��<�f�E�E�E��������+�S�1�1�1����'�D�.�D�0�'�:�:�:�!�E�2�2�	�7�	H�	H�H�
���m�T�8�Y�G�G�G�G�7�	L�	L�I��)�Y�/�/�F����V�S�>��J�
L�
L�
L�
L�.�	H�	H�D����/��t�Y�G�G�G�G�	H�	Hrc��|�t��5ddz}ddd��n#1swxYwY|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��dS)Nrrrr^r�rrhris  r�
test_floordivzLongTest.test_floordivs���
�
�
�0�
1�
1�	�	��Q��A�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
�����#�#�#�����"�%�%�%�����"�%�%�%�����1�%�%�%�����A�&�&�&�����2�&�&�&�����2�&�&�&�����!�$�$�$�����A�&�&�&�����2�&�&�&�����2�&�&�&�����!�$�$�$�$�$rkTc
��|r8tt|��t|����dtzkrdS	tt	||����}n#t
$rd}Ynt$rd}YnwxYw	t||z��}n#t
$rd}Ynt$rd}YnwxYw|�||d�||||����dS)z�Verify that the result of a/b is correctly rounded, by
        comparing it with a pure Python implementation of correctly
        rounded division.  b should be nonzero.rNr��zerodivisionz7Incorrectly rounded division {}/{}: expected {}, got {})	rr+r/r�r8rr,rTr�)rCr1r2�
skip_smallr�r�s      r�
check_truedivzLongTest.check_truedivs*���	�#�c�!�f�f�c�!�f�f�-�-��<��?�?��F�	&��G�A�q�M�M�*�*�H�H���	"�	"�	"�!�H�H�H� �	&�	&�	&�%�H�H�H�	&����	!��q�1�u�+�+�C�C���	�	�	��C�C�C� �	!�	!�	!� �C�C�C�	!����	
����3�)/�/5�v�a��H�c�/J�/J�	L�	L�	L�	L�	Ls/�A�A6�(A6�5A6�:B
�
B)�B)�(B)c�	�|�dd��|�dd��|�dd��|�dd��|�dd��|�ddtzzd��|�dd	dttz
zz��|�ddd
zzd��|�ddd
dzz��dtttttz
f}|D]�}t	|dz
|dz��D]�}|�ddt|d��zzddt|d��zz��|�ddt|d��zzddt|d��zz������ddd
ddd
d
zdddddddzfD]X}t	dd��D]E}|�|tz|z|��|�|tz|z|���F�Yt	d��D]=}|�dtzdzdzddzzd|zzdtzdz���>|�dd��|�d d!��t	d"��D]@}|�d|dzzd|z��|�d|zd|dzz���Addd#d
d$d%dd&dd
d
zdddddddzfD]9}t	dd��D]&}|�dtz|z|z|���'�:t	d'd(��D]}|�|dd)z���d*dd
zdd"zfD]�}t	d"��D]�}tjd|��}tj|d|zdz��}	|�||	��|�||	��|�||	��|�||	������t	d+��D]�}
tjd"��}tjdd"��}tjd|z��}
tjdd|z��}|�|
|��|�|
|��|�|
|��|�|
|����dS),N�{ri8���r^rCige~rrQiNFrjíl90r�Qri0&iCr�rr���i��i����)�2���ri���i�
l�E,J_l�J�brrr�r�� i���i4ld(	r	)	rur�r/r.rLrr-r@�	randrange)rC�basesr�r5�mr#rO�Mr1r2r<�a_bits�b_bitsr
rSs               r�$test_correctly_rounded_true_divisionz-LongTest.test_correctly_rounded_true_division9s���	
���3��"�"�"����4��#�#�#����1�a� � � ����1�b�!�!�!����1�a� � � ����;��K��7��?�?�?����5�&�1�|�k�/I�+J�"J�K�K�K����5��C��<��/�/�/����;��a��e��4�4�4��L�+��k�L�8�:���	P�	P�D��T�B�Y��r�	�2�2�
P�
P���"�"�5��C��Q�K�K��#7��q�#�s�d�A�,�,��9N�O�O�O��"�"�5��C��Q�K�K��#7��q�#�s�d�A�,�,��9N�O�O�O�O�
P�
�Q��2�u�a��f��b�"�c�6�B��F�7�4�	?�	?�A��3��^�^�
?�
?���"�"�1�%5�#5��#9�1�=�=�=��"�"�1�%5�#5��#9�A�2�>�>�>�>�
?�
�s���	2�	2�A�
����<��!� 3�U�:�1�c�6�A�A�q�D�H��l�?�5�0�
2�
2�
2�
2�	
���1�d�#�#�#�	
���0�2G�H�H�H��t���	1�	1�A����r�A�a�C�y�"�a�%�0�0�0����r�1�u�b�1�Q�3�i�0�0�0�0��Q��1�a��R��U�A�s�F��b�"�c�6�B��F�7�4�	=�	=�A��3��^�^�
=�
=���"�"�1�l�?�1�#4�q�#8�!�<�<�<�<�
=��s�B���	+�	+�A����q�!�T�'�*�*�*�*��"�c�'�2�t�8�,�	+�	+�A��4�[�[�
+�
+���$�Q��*�*���$�Q��!��A��.�.���"�"�1�a�(�(�(��"�"�A�2�q�)�)�)��"�"�1�q�b�)�)�)��"�"�A�2��r�*�*�*�*�

+��u���	'�	'�A��%�d�+�+�F��%�a��.�.�F�� ��F��+�+�A�� ��A�v�I�.�.�A����q�!�$�$�$����q�1�"�%�%�%�����r�1�%�%�%�����r�A�2�&�&�&�&�	'�	'rc���|�t��5ddzddd��n#1swxYwY|�t��5dddzzddd��n#1swxYwY|�t��5ddz	ddd��n#1swxYwY|�t��5dddzz	ddd��dS#1swxYwYdS)Nr�rCrr)r�r�r�s r�test_negative_shift_countz"LongTest.test_negative_shift_count�s���
�
�
�z�
*�
*�	�	��"�H�H�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�z�
*�
*�	�	��A��I�,���	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�z�
*�
*�	�	��"�H�H�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�z�
*�
*�	�	��A��I�,���	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	sB�-�1�1�
A(�(A,�/A,�
B�B#�&B#�
C�C�"Cc�|�|�dd��|�dd��|�t��5ddzddd��n#1swxYwY|�dddzzd��|�t��5dddzzddd��dS#1swxYwYdS)Nrrrr)rTr�r�r�s r�test_lshift_of_zerozLongTest.test_lshift_of_zero�sH�������#�#�#�����!�$�$�$�
�
�
�z�
*�
*�	�	�
��G�G�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����q�D�y�)�1�-�-�-�
�
�
�z�
*�
*�	�	�
�1��9����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s$�A�A� A�
B1�1B5�8B5c��|�dtjzd��|�dtjdzzd��dS)Nrr�rTrr2r�s r�test_huge_lshift_of_zeroz!LongTest.test_huge_lshift_of_zero�sH��
	
����c�k�)�1�-�-�-�����s�{�Q��/��3�3�3�3�3rrg�?F)�memuse�dry_runc�r�|�dtjdzzddztjz��dS)Nrrr�)rC�sizes  r�test_huge_lshiftzLongTest.test_huge_lshift�s7��	
����s�{�T�1�2�A��I���4L�M�M�M�M�Mrc�J�ddz}|�d|z	d��|�d|z	d��|�d|z	d��|�d|z	d��|�d	d
z|z	d��|�d	d
z|z	d��dS)Nrrr�ri���rici����rr��rT)rC�
huge_shifts  r�test_huge_rshiftzLongTest.test_huge_rshift�s����$�Y�
�����z�)�1�-�-�-����#�*�,�b�1�1�1������+�Q�/�/�/����%�J�.��3�3�3�����C��:�-�q�1�1�1����!�S�&��J�.��3�3�3�3�3r��g�?c���ddzdztjz}|�|tjdzz	ddzdz��|�|tjdzz	d��dS)Nrr�r�i�rhrr)rr2rT)rCr�r�s   r�test_huge_rshift_of_hugez!LongTest.test_huge_rshift_of_huge�si���c��R��C�K�/������#�+��/�2�Q�#�X��N�C�C�C�����#�+��"4�5�q�9�9�9�9�9rc�x�|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�dd��|�ddzd	z	dd
z��|�ddzd	z	dd
z��|�ddzd	zd	z	dd
z��|�ddzd	zd	z	dd
zd	z
��dS)Nr�i��i��i1i���i���rr�r�r�r�s r�test_small_rshiftzLongTest.test_small_rshift�sV������"�%�%�%�����S�)�)�)�����"�%�%�%�����S�)�)�)�����C�(�(�(�����t�,�,�,�����C�(�(�(�����t�,�,�,�����C��1��a��f�-�-�-����!�S�&��A���3��w�/�/�/����!�S�&�1�*��*�A�s�F�3�3�3����1�c�6�A�:��!�+�a��f�W�q�[�9�9�9�9�9rc��|�dd��|�dd��|�dd��|�dd��|�ddzdz	ddz��|�ddzdz	ddz��|�dttzz
tz	t��|�tdz
ttzz
tz	t��dS)	NrrrrCr�r��wr)rT�BASEr>r�s r�test_medium_rshiftzLongTest.test_medium_rshift�s�������!�$�$�$�����R�(�(�(�����A�&�&�&�����r�*�*�*�����C��1��a��f�-�-�-����!�S�&��A���3��w�/�/�/�	
���!�d�4�i�-�E�1�D�5�9�9�9����$��(�T�$�Y�.�5�8�4�%�@�@�@�@�@rc�6�|�dd��|�dd��|�dd��|�dd��|�ddzdz	ddz��|�ddzdz	ddz��dS)Nrrrr�r��`r�r�s r�test_big_rshiftzLongTest.test_big_rshift�s�������1�%�%�%�����b�)�)�)�����Q�'�'�'������+�+�+�����C��2��q�"�u�-�-�-����!�S�&��B���B���/�/�/�/�/rc�6�|�dd��|�dd��|�dd��|�dd��|�ddzdzddz��|�ddzdzddz��dS)	N�Ti����ibi����rr�rr�r�r�s r�test_small_lshiftzLongTest.test_small_lshift�s�������"�%�%�%�����S�)�)�)�����4�(�(�(�����e�,�,�,�����C��1��a��f�-�-�-����!�S�&��A���3��w�/�/�/�/�/rc��|�dd��|�dd��|�dd��|�dd��dS)NiTi���i�i<��r�r�s r�test_medium_lshiftzLongTest.test_medium_lshift�s`������%�(�(�(�����V�,�,�,�����F�+�+�+�����w�/�/�/�/�/rc�6�|�dd��|�dd��|�dd��|�dd��|�ddzdzddz��|�ddzdzddz��dS)	Nl�l�����l�l�����rr�r��r�r�s r�test_big_lshiftzLongTest.test_big_lshift�s�������:�.�.�.�����k�2�2�2�����\�2�2�2�����
�6�6�6�����C��2��q�#�v�.�.�.����!�S�&��B���C���0�0�0�0�0rc��ddz}|dz}|dz}|�||zd��|�||z
d��dS)Nrrjr)�assertIs)rCr1r2�cs    r�#test_small_ints_in_huge_calculationz,LongTest.test_small_ints_in_huge_calculation�sU��
��H��
�B��F��
��E���
�
�a�!�e�Q�����
�
�a�!�e�Q�����rc�d�|�tddd��d��|�dd��d\}}}|�||z|zd��|�tddd��d��|�dd��d	\}}}|�||z|zd��|�tdd
dd
zdz
��d��|�dd
zdd
zdz
zd��dd
dd
zdz
}}}|�||z|zd��dS)Nrir^��r)rir^r��r�r)rr�r�rj)r��pow)rCr1r�r�s    r�test_pow_uses_cached_small_intsz(LongTest.test_pow_uses_cached_small_intss;���
�
�c�"�a��o�o�q�)�)�)��
�
�m�Q�'�'�'����1�a��
�
�a�1�f�q�j�!�$�$�$��
�
�c�!�R��-�-�q�1�1�1��
�
�-�q�1�1�1�$���1�a��
�
�a�1�f�q�j�!�$�$�$��
�
�c�!�S�!�S�&�1�*�-�-�q�1�1�1��
�
�a�3�h�!�s�(�Q�,�/��3�3�3��S�!�S�&�1�*�a�1���
�
�a�1�f�q�j�!�$�$�$�$�$rc��ddz}|�|dz|zd��|�|dz|zd��|�||dzzd��|�||dzzd��td|zdz|��\}}|�|d��|�|d��td|zdz|��\}}|�|d��|�|d��td|zdz
|��\}}|�|d��|�|d��td|zdz
|��\}}|�|d��|�|d��dS)	Nrirjrrr�r^rrC)r�r0)rC�bigr)r6s    r�"test_divmod_uses_cached_small_intsz+LongTest.test_divmod_uses_cached_small_intss����C�i���
�
�s�Q�w�#�o�q�)�)�)��
�
�s�Q�w�3�&��*�*�*��
�
�c�c�Q�h�'��+�+�+��
�
�c�c�R�i�(�"�-�-�-��a�#�g��k�3�'�'���1��
�
�a������
�
�a������b�3�h��n�c�*�*���1��
�
�a������
�
�a������a�C�4�j�1�n�s�d�+�+���1��
�
�a������
�
�a������a�#�g��k�C�4�(�(���1��
�
�a������
�
�a������rc	��tdd��D�]=}|�||dz��|�||dz��|�||dz
��|�||dz��|�||dz��|�||dz��|�||dz��|�||��|�||dz��|�|tt|������|�||dzdz	t|������?d}|�||z
d��|�d|zd��dS)Nrz�rrrrl)rLr�r?r�)rCrOs  r�test_small_intszLongTest.test_small_ints1ss���r�3���	.�	.�A��M�M�!�Q��U�#�#�#��M�M�!�Q��U�#�#�#��M�M�!�Q��U�#�#�#��M�M�!�Q�!�V�$�$�$��M�M�!�Q��V�$�$�$��M�M�!�Q��U�#�#�#��M�M�!�Q��U�#�#�#��M�M�!�q�b�S�!�!�!��M�M�!�Q��T�"�"�"��M�M�!�S��Q���[�[�)�)�)��M�M�!�Q��T�1�W�c�!�f�f�-�-�-�-����
�
�a�!�e�Q�����
�
�a�!�e�Q�����rc��d}tdd��D�]}|���}|�|tt	|���d������|dkr:|�d|dz
zt|��cxkod|zknc��n|�|d��|dkrb|�|dtj	tj
t|����tj
d��z|z��z����|�d���d��|�d���d��|�d���d��|�d���d��|�d	���d��d
D�]}d|z}|�|dz
���|��|�d|z
���|��|�|���|dz��|�|���|dz��|�|dz���|dz��|�|dz
���|dz����dS)Ng�����|�=i��i�z-0brrrrr)rr^rr�ryr�r��!�?�@��)rLrrT�lenr��lstriprBr+r �floorr
)rC�tinyr
�krOr1s      r�test_bit_lengthzLongTest.test_bit_lengthCs������v�u�%�%�	>�	>�A������A����Q��C��F�F�M�M�%�$8�$8� 9� 9�:�:�:��A�v�v�����A�a�C��C��F�F� 9� 9� 9� 9�Q��T� 9� 9� 9� 9�:�:�:�:�� � ��A�&�&�&��A�v�v�
� � ��A��
����Q���(�(���!���4�t�;�)=�)=�%=�>�>�>��	
���!���)�)�1�-�-�-����!���)�)�1�-�-�-����"���*�*�A�.�.�.����!���)�)�1�-�-�-����"���*�*�A�.�.�.�<�	7�	7�A��1��A����a��c�-�-�/�/��3�3�3����a��c�-�-�/�/��3�3�3����a�^�^�-�-�q��s�3�3�3����q�b�_�_�.�.��!��4�4�4����a��c�-�-�/�/��1��5�5�5����q�b��d�.�.�0�0�!�A�#�6�6�6�6�	7�	7rc�.�tdd��D]J}|�|���t|���d�����KdD]�}d|z}|�|���d��|�|dz
���|��|�|dz���d��|�|dz
d	z���|d
z
����dS)Ni���rr>)riryr�r��Ai�iZi��rrr�ri�r�)rLrT�	bit_countr��count)rCr1r5s   r�test_bit_countzLongTest.test_bit_countes���u�d�#�#�	?�	?�A����Q�[�[�]�]�C��F�F�L�L��,=�,=�>�>�>�>�=�	C�	C�C��3��A����Q�[�[�]�]�A�.�.�.����a�!�e�.�.�0�0�#�6�6�6����a�"�f�/�/�1�1�1�5�5�5����q�1�u��m�6�6�8�8�#��'�B�B�B�B�	C�	Crc�
�idd�dd�dd�dd�dd�dd�dd�d	d�d
d�dd�dd�dd�d
d�dd�dd�dd�dd�dddd��}tddd��D]r}|���D][\}}t||zd��}||z}|�||��|�t|��t���\�s|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�tdd��d��|�td d��d��|�td!d��d"��|�td#d��d"��|�td$d��d%��|�td&d��d%��|�td'd��d(��|�td)d*��d+��|�td,d*��d-��|�td.d��d/��|�td.d��d0��|�td.d*��d1��|�td.d2��d3��|�td.d4��d5��|�td.d6��d7��|�td.d8��d9��|�td.d:��d;��|�td.d<��d=��|�td.d>��d?��|�td.d@��d��|�td.dA��d��|�td.dB��d��tdd"��D]^}td|zdCzd*��}d|zdDz}|�||��|�t|��t���_td��D]w}td"��D]e}	tjdEdF��}
t|
|��}|�||
��|�t|��t���f�xdGdHdIdJdd"zdd"zfD]&}|�tdK|��dK���'td"��D]d}	tjdEdF��}
t|
��}|�||
��|�t|��t���edL}|D]$}
|�	ttd|
���%dS)MNrrrr^rrhr�rirr�r�r�r�r�r]rr�r�)ry��i����irij���ri8���ik���r]i���i���i����1r|�3rj��rr~�i,iԡrCi�i��i��l!l!l�~!l�!r�l�!rzl`!i����l!rgl'�!i����lz+i����lv|or}l,Gxi����i�i���iF�i��i���r	r�r�r�r�i{�)�brianr�y)rL�items�roundrTr��typer?r@r�r�r�)rC�	test_dict�offsetr�r�r�r��expectr#rOr
�huge_n�
bad_exponentsrs              r�
test_roundzLongTest.test_roundps���8�Q�q�8�!�A�8�q��8�A�a�8��1�8�a��8��r�8��R�8�!"�2�8�'(��8�-/��8�46�r�8�;=�b�8�BD�R�8�IK�B�8���8��r�8�&(�R�B�8�8�8�	��D�#�r�*�*�	.�	.�F�!���)�)�
.�
.���1��A�f�H�b�)�)���V�8��� � ��h�/�/�/��
�
�d�3�i�i��-�-�-�-�	
.�	
����t�R���$�/�/�/�����t�R���$�/�/�/�����s�B����.�.�.�����s�B����+�+�+�����s�B����+�+�+�����r�2����*�*�*�����q�"���q�)�)�)�����q�"���q�)�)�)�����r�2����*�*�*�����r�2����*�*�*�����r�2����,�,�,�����s�B����-�-�-�����s�B����-�-�-�����s�B����-�-�-�����s�B����-�-�-�����v�r�*�*�F�3�3�3�����v�r�*�*�F�3�3�3�����{�B�/�/��=�=�=�����{�B�/�/��=�=�=�����{�B�/�/��=�=�=�����{�B�/�/��=�=�=�����{�B�/�/��=�=�=�����{�B�/�/��=�=�=�����{�B�/�/��=�=�=�����{�B�/�/��=�=�=�����{�B�/�/��=�=�=�����{�C�0�0�+�>�>�>�����{�C�0�0�!�4�4�4�����{�C�0�0�!�4�4�4�����{�D�1�1�1�5�5�5��r�3���	*�	*�A���A�����+�+�C���U�V�^�F����S�&�)�)�)��M�M�$�s�)�)�S�)�)�)�)��q���	.�	.�A��3�Z�Z�
.�
.���$�V�U�3�3���A�q�k�k��� � ��a�(�(�(��
�
�d�3�i�i��-�-�-�-�	
.�
�u�g�u�a��f�b�#�g�E�	>�	>�F����U�7�F�3�3�W�=�=�=�=��s���	*�	*�A�� ���/�/�A���(�(�C����S�!�$�$�$��M�M�$�s�)�)�S�)�)�)�)�+�
��	6�	6�A����i���1�5�5�5�5�	6�	6rc����d=�fd�	}idd�dd�dd�d	d
�dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd �d!d"�d#d$�}||d%d&�'��idd�dd�dd�d	d
�dd�d
d�dd�dd(�dd)�dd�dd�dd*�dd�dd+�dd,�d!d-�d#d.�}||d/d&�'��dddddddd0d1d2d3�
}||d%d�'��dddddd*dd+d1d4d3�
}||d/d�'����tdjdd%d�'����tdjdd%d&�'����tdjdd/d�'����tdjdd/d&�'����tdjd5d%d�'����tdjd5d/d�'����d�dd%��d6����d�d7d%��d8����d�d7d%��d9����d�d7d%d&�'��d:����tdjdd%��Gd;�d<t��}��d�d|d%����d����d�d|d/����d6��dS)>NFc	����d	d�}|���D�]Z\}}	��|�t|��||���|��n7#t$r*}td�|||����|�d}~wwxYwt|��dkrg|dkra|s_	��|���|��n5#t$r(}td�|����|�d}~wwxYw	��||t|��||���|����%#t$r*}td�|||����|�d}~wwxYwdS)
NFc���|dkrt|��}n"|dkrtt|����}t�fd�|D����S)N�littler�c3�.�K�|]}�|dzz	dzV��dS)r��Nr
)rrOr#s  �rr�zSLongTest.test_to_bytes.<locals>.check.<locals>.equivalent_python.<locals>.<genexpr>�s0�����>�>�1�a�1�Q�3�h�$�.�>�>�>�>�>�>r)rL�reversed�bytes)r#�length�	byteorder�signed�orders`    r�equivalent_pythonz@LongTest.test_to_bytes.<locals>.check.<locals>.equivalent_python�s\�����(�(�!�&�M�M�E�E��%�'�'�$�U�6�]�]�3�3�E��>�>�>�>��>�>�>�>�>�>r�r�z4failed to convert {} with byteorder={} and signed={}rr��+failed to convert {} with default argumentszmCode equivalent from docs is not equivalent for conversion of {0} with byteorder byteorder={1} and signed={2}�F)r�rT�to_bytesr��	Exception�AssertionErrorr���testsr�r�r�rr��errrCs       �r�checkz%LongTest.test_to_bytes.<locals>.check�s���
?�
?�
?�
?�#(�+�+�-�-�
O�
O���h�C��$�$��
�
�c�(�m�m�Y�v�
�N�N� �"�"�"�"��!�C�C�C�(�N����i��8�8�:�:�?B�C�����C�����x�=�=�A�%�%�)�u�*<�*<�V�*<�4��(�(������(�C�C�C�C��$�4�4�4�,�I�#�V�D�\�\�+�+�03�4�����4����

O��$�$�)�)� �#�h�-�-��6�K�K�K� ������
!�O�O�O�(�%�%+�V�D�)�V�%D�%D�F�F�LO�O�����O����3
O�
OsG�9A�
B�%%B
�
B�.(C�
D	�!#D�D	�
0D?�?
E3�	%E.�.E3r�r�r�������r���������r�����������������r������������s����������������r�Tr���������������r�������)
rrr�r�r�rr��r��rrrhsss�����c��eZdZdS)�&LongTest.test_to_bytes.<locals>.SubStrN�r�r�r�r
rr�SubStrr:��������Drr!r�)r�rr�rTr�)rCr��tests1�tests2�tests3�tests4r!s`      r�
test_to_byteszLongTest.test_to_bytes�s����%	O�%	O�%	O�%	O�%	O�%	O�P
�
�w�
�
�w�
�
��
�
�'�	
�

�'�
�
�+�

�
��
�
��
�
�+�
�
�+�
�
��
�
��
�
�;�
�
�O�
�
�?�
� 
�O�!
�"
�o�#
��&	��f�e�D�)�)�)�)�
�
�w�
�
�w�
�
��
�
�'�	
�

�'�
�
�+�

�
��
�
��
�
�+�
�
�+�
�
��
�
��
�
�;�
�
�K�
�
�?�
� 
�O�!
�"
�o�#
��&	��f�h�t�,�,�,�,����������"�
�
��	��f�e�E�*�*�*�*����������"�
�
��	��f�h�u�-�-�-�-����-�#���E�%��P�P�P����-�#���E�$��O�O�O����-�#���H�U��S�S�S����-�#���H�T��R�R�R����-�"���5���O�O�O����-�"���8�E��R�R�R����!���a��/�/��5�5�5����!���a��/�/�1H�I�I�I����!���a��/�/�1H�I�I�I����"���q�%���=�=�0�	2�	2�	2����-�!��q�%�@�@�@�	�	�	�	�	�S�	�	�	����!���a������7�7��A�A�A����!���a����)9�)9�:�:�C�@�@�@�@�@rc���dM�fd�	}idd�dd�dd�dd�d	d�d
d�dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd �d!d"d#d$d%��}||d&d'�(��idd�dd�dd�dd�d	d�d
d�dd�d
d�dd�dd�dd�d)d�d*d�dd�dd�d	d�dd �d!d"d#d$d+��}||d,d'�(��ddddd-ddd d.d"d/d0�}||d&d�(��ddddd-ddd d.d"d/d1�}||d,d�(��Gd2�d3t��}��t|�dd&����|����|�dd&��d����t|�dd&d�(����|����|�dd&d�(��d����t|�dd,����|����|�dd,��d����t|�dd,d�(����|����|�dd,d�(��d����t�gd4�d&d'�(��d#����t�d4d&d'�(��d#����t�td5��d&d'�(��d#����t�td5��d&d'�(��d#����t�t
jd6d5��d&d'�(��d#����t�td5��d&d'�(��d#����ttjdgd&����ttjdgd7����ttjdgd8����ttjd9d&����ttjd:d&����ttjdd&����ttjdd&d'����t|jd9d&����t|jd:d&����t|jdd&����ttjdd&d'��Gd;�d<t��}|�dd&��}��t|��|����|d=��Gd>�d?t��}	|	�dd&��}��t|��|	����|d����t|d@dA��dB��GdC�dD��}
GdE�dF��}GdG�dH��}GdI�dJ��}
��t�|
����d����ttj|������ttj|������ttj|
����GdK�dLt��}��t�d|d&����d����t�d|d,����d��dS)NNFc	���dd�}|���D�]7\}}	��t�|||���|��n7#t$r*}td�|||����|�d}~wwxYw|dkrg|se	��t�|��|��n5#t$r(}td�|����|�d}~wwxYw	��||||���|����#t$r*}td�|||����|�d}~wwxYwdS)	NFc��|dkrt|��}n"|dkrtt|����}td�t|��D����}|r%|r#|ddzr|ddt	|��zzz}|S)Nr�r�c3�,K�|]\}}||dzzV��dS)r�Nr
)rrOr2s   rr�zULongTest.test_from_bytes.<locals>.check.<locals>.equivalent_python.<locals>.<genexpr>Gs.����G�G�T�Q���Q�q�S��G�G�G�G�G�Grrr�rr�)r_r��sum�	enumerater�)�
byte_arrayr�r��little_orderedr#s     rr�zBLongTest.test_from_bytes.<locals>.check.<locals>.equivalent_pythonAs�����(�(�%)�*�%5�%5�N�N��%�'�'�%)�(�:�*>�*>�%?�%?�N��G�G�Y�~�-F�-F�G�G�G�G�G���4�n�4�.��2D�t�2K�4���a��N� 3� 3�3�3�3�A��rr�z6failed to convert {} with byteorder={!r} and signed={}r�r�zeCode equivalent from docs is not equivalent for conversion of {0} with byteorder={1!r} and signed={2}r�)r�rTr?�
from_bytesr�r�r�r�s       �rr�z'LongTest.test_from_bytes.<locals>.check@s����

�

�

�

�#(�+�+�-�-�
C�
C���h�C��$�$����t�Y�v��F�F� �"�"�"�"��!�C�C�C�(�P����i��8�8�:�:�?B�C�����C������%�%�f�%�4��(�(��N�N�4�0�0�$�&�&�&�&��%�4�4�4�,�I�#�V�D�\�\�+�+�03�4�����4����
	C��$�$�)�)�$�	�&�I�I�I� ������!�C�C�C�(�P����i��8�8�:�:�@C�C�����C����5
C�
CsG�1A�
B�%B�B�.C�
C4�#C/�/C4�8"D�
E�&%E�Errr�sr�rrr�rrr�r�r�r�r�r�r�r�rr�rrrrrr�rrr	rr
rr
r)rrrrr�Tr�rr)rrrrr�r�rr)rr�r�r�r�r�rr	rrr)rr�r�r�r�r�rr�rrrc��eZdZdS)�'LongTest.test_from_bytes.<locals>.myintNr r
rr�myintr2�r"rr3)r�rrr�Bzbigzlittler��c��eZdZd�ZdS)�(LongTest.test_from_bytes.<locals>.myint2c�>�t�||dz��S)Nr)r?�__new__)�clsr�s  rr9z0LongTest.test_from_bytes.<locals>.myint2.__new__�s���{�{�3���	�2�2�2rN�r�r�r�r9r
rr�myint2r7�s#������
3�
3�
3�
3�
3rr<rc��eZdZd�ZdS)�(LongTest.test_from_bytes.<locals>.myint3c��d|_dS)N�bar)�foo)rCr�s  rrz1LongTest.test_from_bytes.<locals>.myint3.__init__�s
�� ����rN)r�r�r�rr
rr�myint3r>�s#������
!�
!�
!�
!�
!rrBrA�noner@c��eZdZd�ZdS)�,LongTest.test_from_bytes.<locals>.ValidBytesc��dS)Nr�r
r�s r�	__bytes__z6LongTest.test_from_bytes.<locals>.ValidBytes.__bytes__�s���wrN�r�r�r�rGr
rr�
ValidBytesrE�s#������
�
�
�
�
rrIc��eZdZd�ZdS)�.LongTest.test_from_bytes.<locals>.InvalidBytesc��dS)N�abcr
r�s rrGz8LongTest.test_from_bytes.<locals>.InvalidBytes.__bytes__�s���urNrHr
rr�InvalidBytesrK�s#������
�
�
�
�
rrNc��eZdZdS)�.LongTest.test_from_bytes.<locals>.MissingBytesNr r
rr�MissingBytesrP�s�������rrQc��eZdZd�ZdS)�.LongTest.test_from_bytes.<locals>.RaisingBytesc��ddzdS)Nrrr
r�s rrGz8LongTest.test_from_bytes.<locals>.RaisingBytes.__bytes__�s���A����rNrHr
rr�RaisingBytesrS�s#������
�
�
�
�
rrUc��eZdZdS)�(LongTest.test_from_bytes.<locals>.SubStrNr r
rrr!rWr"rr!r�)r?r�r�r0rT�	bytearray�array�
memoryviewr�r�r��getattrr,r�)rCr�r#r$r%r&r3r<rOrBrIrNrQrUr!s`              r�test_from_byteszLongTest.test_from_bytes?s�	���+	C�+	C�+	C�+	C�+	C�+	C�\
���
��Q�
�
��
�
�Q�	
�

��
�
�R�

�
��
�
�T�
�
�T�
�
��
�
�S�
�
��
�
��
�
��
�
��
� 
��!
�"
��#
�$ �"�#�%�+
�
�
��.	��f�e�D�)�)�)�)�
���
��Q�
�
��
�
�Q�	
�

��
�
�R�

�
��
�
�T�
�
�T�
�
��
�
�S�
�
��
�
��
�
��
�
��
� 
��!
�"
��#
�$ �"�#�%�+
�
�
��.	��f�h�t�,�,�,�,�����������"�
�
��	��f�e�E�*�*�*�*�����������"�
�
��	��f�h�u�-�-�-�-�	�	�	�	�	�C�	�	�	�	
�
�
�d�5�+�+�G�U�;�;�<�<�e�D�D�D�����)�)�'�5�9�9�1�=�=�=��
�
���!�!�'�5��!�?�?�@�@�%�	I�	I�	I�����)�)�'�5��)�G�G��K�K�K��
�
�d�5�+�+�G�X�>�>�?�?��G�G�G�����)�)�'�8�<�<�a�@�@�@��
�
�d�5�+�+��X�e�,�-�-�.�.�/4�	6�	6�	6�����)�)�'�8�E�)�J�J�A�N�N�N�����N�N�;�;�;��d�N�;�;�V�	E�	E�	E�����N�N�;��d�N�;�;�V�	E�	E�	E��������o�&�&��d�(�<�<�=C�	E�	E�	E��������o�&�&��d�(�<�<�=C�	E�	E�	E��������K��_�-�-�u�T�(�C�C�DJ�	L�	L�	L���������'�'��t�(�=�=�>D�	F�	F�	F����*�c�n�s�e�U�C�C�C����*�c�n�q�c�9�E�E�E����*�c�n�q�c�<�H�H�H����)�S�^�R��?�?�?����)�S�^�V�U�C�C�C����)�S�^�Q��>�>�>����)�S�^�Q��t�D�D�D����)�U�%5�r�5�A�A�A����)�U�%5�v�u�E�E�E����)�U�%5�q�%�@�@�@����)�S�^�Q��t�D�D�D�	3�	3�	3�	3�	3�S�	3�	3�	3�
���g�u�-�-���
�
�d�1�g�g�v�&�&�&�����A����	!�	!�	!�	!�	!�S�	!�	!�	!�
���g�u�-�-���
�
�d�1�g�g�v�&�&�&�����A���������E�6�2�2�E�:�:�:�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	 ��������	�	�	�	�	�	�	�	�	
������
�
���5�5�q�9�9�9����)�S�^�\�\�^�^�D�D�D����)�S�^�\�\�^�^�D�D�D����+�S�^�\�\�^�^�L�L�L�	�	�	�	�	�S�	�	�	��������V�V�E�]�]�;�;�Q�?�?�?�����������1A�1A�B�B�A�F�F�F�F�Frc��tdd��D]I}|�dd���}|�t�|d���|���JdS)Nrzr�rTr�)rLr�r�r?r0)rCrOr2s   r�test_from_bytes_smallzLongTest.test_from_bytes_small
sa���r�3���	=�	=�A��
�
�1�T�
�*�*�A��M�M�#�.�.��4�.�8�8�!�<�<�<�<�	=�	=rc���Gd�dt����fd�td��D��}tt|��D]}|�|d���dS)Nc��eZdZdd�ZdS)�<LongTest.test_access_to_nonexistent_digit_0.<locals>.Integerrc�J�t�||��}d|_|S)NrA)r?r9rA)r:r�rCs   rr9zDLongTest.test_access_to_nonexistent_digit_0.<locals>.Integer.__new__s!���{�{�3��.�.�� ����rN�rr;r
rr�Integerras(������
�
�
�
�
�
rrdc�&��g|]
}�d����Srcr
)rrOrds  �rrz?LongTest.test_access_to_nonexistent_digit_0.<locals>.<listcomp>s!���4�4�4�1�G�G�A�J�J�4�4�4rrr)r?rL�maprT)rC�integersr#rds   @r�"test_access_to_nonexistent_digit_0z+LongTest.test_access_to_nonexistent_digit_0s����	�	�	�	�	�c�	�	�	�5�4�4�4��d���4�4�4���S�(�#�#�	#�	#�A����Q��"�"�"�"�	#�	#rc���dD]]}dD]X}|�t||z��t��|�t||z	��t���Y�^dS)N)TF)rr)rTr�r?)rCr�r(s   r�test_shift_boolzLongTest.test_shift_bool"sv��"�	<�	<�E��
<�
<��� � ��e�u�n�!5�!5�s�;�;�;�� � ��e�u�n�!5�!5�s�;�;�;�;�
<�	<�	<rc
��Gd�dt��}ddddtjdzdd|d	��g}|D]�}|���\}}|�||ft|��df��|�t|��t��|�t|��t����dS)
Nc��eZdZdS)�-LongTest.test_as_integer_ratio.<locals>.myintNr r
rrr3rm*r"rr3rirr}rTFr�)r?rr2�as_integer_ratiorTr�)rCr3r�r��	numerator�denominators      r�test_as_integer_ratiozLongTest.test_as_integer_ratio)s���	�	�	�	�	�C�	�	�	��Q��Q���a���u�e�e�B�i�i�H���	5�	5�E�%*�%;�%;�%=�%=�"�I�{����i��5��E�
�
�A��G�G�G����T�)�_�_�c�2�2�2����T�+�.�.��4�4�4�4�		5�	5rc	���tdd��D]d}d|zdz
}|�||���5|�|dzdd|zzd|dzzz
dz��ddd��n#1swxYwY�edS)Nri�)�bitlenr#r)rLrUrT)rCrsr#s   r�test_squarezLongTest.test_square3s���
�A�s�m�m�	C�	C�F��f���!�A����V�q��1�1�
C�
C�� � ��A���1�v�:�&�1��!��+<�=��A�C�C�C�
C�
C�
C�
C�
C�
C�
C�
C�
C�
C�
C����
C�
C�
C�
C��	C�	Cs�,A*�*A.	�1A.	N)T)=r�r�r�rJrPr[rfrprsrvryr|r�r�r�r�r�r�r�requires_IEEE_754r�rrr8rarerjrorqrur�r�r��cpython_onlyr��
bigmemtestrr2r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r'r\r^rhrjrqrtr
rrr:r:ssJ���������0���
C�
C�
C�#>�#>�#>�N+�+�+�.+�+�+�6+�+�+�/�/�/�
S�
S�
S�>�>�>�1�1�1�'�'�'�6M�6M�6M�r5�5�5�"0�0�0�"
��C0�C0���C0�J8�8�8�>;�;�;�$Z*�Z*�Z*�x_D�_D�_D�B9�9�9�
&�&�&� H� H� H�D%�%�%�&L�L�L�L�<
��Y'�Y'���Y'�v������
��4�4���4�
���W����d�*�8�U�K�K�K�N�N�L�K���N�4�4�4�
���W����c�)�$��F�F�F�:�:�G�F���:�
:�:�:� 
A�
A�
A�0�0�0�0�0�0�0�0�0�1�1�1�
�� � ��� �
��%�%���%� 
�������0 � � �$ 7� 7� 7�D	C�	C�	C�H6�H6�H6�TCA�CA�CA�JLG�LG�LG�\
��=�=���=�#�#�#�<�<�<�5�5�5�
C�
C�
C�
C�
Crr:�__main__)#�unittestrrrr@r rY�int_info�bits_per_digitr>r�rNrar`r{rrrLrOrbrrr�rr��min_expr.rr/r-rr8�TestCaser:r��mainr
rr�<module>rs�������������
�
�
�
�
�
�
�
���������	��#���E�z���a�x����
�	�
�a��D�$�!�)�%7�9K�
L����	��q��w�����A��N�N�2��6����	�q��B�B��� � �� � � �#8�#8��#8�#8�#8�8�8��

�.�
���n�$���n�$���~�&���k�>�A��l�(B�Q�(F�$G�G��*'�*'�*'�\+�+�+�<JC�JC�JC�JC�JC�x� �JC�JC�JC�X.�z����H�M�O�O�O�O�O��r