python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_long.cpython-312.pyc

ΑeTddlZddlmZddlZddlZddlZddlZejjZ	de	zZ
e
dz
ZdZdZ
ddde
e
dz	ddgZd	Zede	zD]Zej%edz
edzZ[eeDcgc]}|c}eDcgc]}|c}zz
Zej&j(Zej&j,Zej&j0Zej&j4Zdezdeez
dz
zz
Zd
ZdZGdd
ej>Z e!dk(rejDyycc}wcc}w)N)supportFlUU*UU*l*UU*UU
cHtjjdz}tjj|z
}d|z}gd}|dk(ry|dkr
t	|S|j|z
}|dkr||zn||z	t
|d|zzz}|||dzz
}|||k(z|kDrtd|d	zdk(r#|d	zdtjjzksJ|d|zztjjksJtjt||S)
z9
    Correctly-rounded integer-to-float conversion.

    rr)rrrr
rrrr
z%integer too large to convert to floatr)sys
float_infomant_digmax_expint_to_float
bit_lengthbool
OverflowErrormaxmathldexpfloat)n	PRECISION	SHIFT_MAXQ_MAXROUND_HALF_TO_EVEN_CORRECTIONshiftqs       B/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_long.pyrr's/''!+I&&2I
NE$?!	Av	
QaR   
LLNY&EqyeVqEzT!en:L5M&MA	&q1u	--A
U
i'CDD
q5A:!q&A(?(?$@@@q%x<3>>----::eAh&&c||zdk}t|t|}}|std|t|zk\rtd|j	|j	z
}|dk\r|d|z|zk\s|dkr|d|zz|k\r|dz
}t|ttz
}|t|dz|t|dz}}t||\}}d|z|kDsd|z|k(r
|dzdk(r|dz
}tj||}|r|S|S)z-Correctly-rounded true division for integers.rzdivision by zeroz)int/int too large to represent as a floatrr)absZeroDivisionErrorDBL_MIN_OVERFLOWrrrDBL_MIN_EXPDBL_MANT_DIGdivmodrr)abnegativedexpr rresults        r!truedivr1Us#sQwHq63q6qA
 233q  GHH	
'AAv!q!tax-1q5QQBY!^	Qa

,CSD!a3sA;.qA!Q<DAq	sQw!A#(q1uz	Q
ZZ3
FF7*F*r"ceZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZej&dZdZdZdZdZdZdZdZdZd>dZej&dZdZdZ ejBdZ"ejBejFe$jJdzdd !d"Z&d#Z'ejBejFe$jJd$zd%d !d&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.ejBd-Z/ejBd.Z0ejBd/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7ejBd6Z8d7Z9d8Z:d9Z;d:Z<d;Z=d<Z>y=)?LongTestc.|j|d|tz}|tz
dz}d}d}ttjtdzzdz}||kr|dz	dz}t	|||z
}|jd|cxkxr	tknc||z}||z}|dzr|d|zdz
z}ttjtdzz}||kr|j||cxkxr|knctjdkr|}|S)Nrrr?)
assertGreaterSHIFTintrandommin
assertTrue)selfndigitsnbits_hinbits_loanswernbitsr/bitss        r!getranzLongTest.getran{s7A&U?e#a'

519-.2hFa<DtX-.DOOA../DLEt^F1uAI?3FMMOuqy12Ah	
E5X56==?S WF
r"cd}t|D]&}|tztjdtz}(tjdkr|}|S)Nrr5)ranger7r9randintMASK)r=r@is   r!getran2zLongTest.getran2sOw	AAo4)@@F	A==?S WF
r"c|j}|j||5t||\}}||z||z}}||z||z}	}|||	d|||d|||d||||z|zd|dkDr!|jd|cxkxr|kncdn |j||cxkxrdkncddddy#1swYyxYw)Nxyzmultiplication does not commutez(divmod returns different quotient than /z#divmod returns different mod than %zx != q*y + r after divmodrzbad mod from divmod)assertEqualsubTestr)r;)
r<rLrMeqr r/q2r2pabpbas
          r!check_divisionzLongTest.check_divisions



\\A\
#	C!Q<DAqT1Q3BsAaCCsC:;q"@Aq";<q!A#'671uQ

,ABA

,AB	C	C	CsBCC
cttdtdzttttdzz}|j	tdz|D]A}|j|}|D])}|j|xsd}|j
||+C|j
dd|j
dd|j
dd	|j
d
d|j
dd
|j
dd|j
dd|j
dd|j
dd|j
dd|j
dd|j
ddy)Nrl!Us/w3alZW3al+Q@{dB]OlNlOOlNlteo%gqCgx<l&ghrsGlQ5K4+o-bklC4+o-bkl.#wflD&I-XlZnSu9blcv
<IlrdFBu'plPhbIi|$l1m{Wqi8ls~5^Fiy+l'H
<{Cl`<{ClED_5(Nloybal=2zz6l9tm)listrE	MAXDIGITSKARATSUBA_CUTOFFappendrCrU)r<digitslenxrLlenyrMs      r!
test_divisionzLongTest.test_divisions|eAy{+,tE:J6F6K5M0NN

&*+	*DD!A
*KK%*##Aq)
*	*	
8/	1@)	+@)	+A3	5	
@2	4@3	5	
NI6/;.	:.?.?,n=r"cttddttttdzz}|jtdztdzg|Dcgc]}|tz
}}|D]i}d|zdz
}|D]Z}||kr	|j||5d|zdz
}||z}d||zzd|zz
d|zz
dz}	|j
||	ddd\kycc}w#1swYnxYw)Nr
d)abitsbbits)rYrEr[extendr7rOrN)
r<r]digitrBrer*rfr+rLrMs
          r!test_karatsubazLongTest.test_karatsubas'eAqk"T%0@0@20E+G&HH

'",.>.DEF+12%
22	+Eeq A

+5=\\U\;+eq(AAA
.u*&u*&A$$Q*++

+	+	3++sC7C""C+c|j}|j|5||dzd||dz|||dz|||dz|||dzd||dz|||||||z||||z||||zd|||zd|||zd|||zd||d|z|||dz
dddtdtzD]x}d|z}|j|||5|||z|z	||||z||z	|||z||z|||z||z	|z|||z||dz
zdddzy#1swYxYw#1swYxYw)NrLrr
rr)rLrp2)rNrOrEr7)r<rLrPrrls     r!check_bitop_identities_1z!LongTest.check_bitop_identities_1s



\\A\
	q1uaLq1uaLq1uaLq2vqMq2vrNq2vrNqA2#Jq1uaLq1uaLq1uaLqA2vqMqA2vrNqA2vrNr1r6NrQqS6N	 qw	+AaBQ2.
+16Q;"17AF#1r616"1s7AFaK(1s7A"q&	M*
+
+	+!		$
+
+sB<E1AE=1E:=F	c|j}|j||5|||z||z|||z||z|||z||z|||z|z||||z||z|||z||z|||z||z||zz|||z||z||zz|||z||z||zzdddy#1swYyxYw)NrKrNrO)r<rLrMrPs    r!check_bitop_identities_2z!LongTest.check_bitop_identities_2s



\\A\
#		+q1ua!eq1ua!eq1ua!eq1uqy!q1uaRj!q1uaRj!q1uq1u!a%()q1uqA2v1"q&)*q1uq1u!qb)*		+		+		+sB%CCcL|j}|j|||5|||z|z|||zz|||z|z|||zz|||z|z|||zz||||zz||z||zz||||zz||z||zzdddy#1swYyxYw)N)rLrMzro)r<rLrMrrrPs     r!check_bitop_identities_3z!LongTest.check_bitop_identities_3s



\\Aa\
(	/A{AQK(A{AQK(A{AQK(qAE{QUq1u-.qAE{QUq1u-.	/	/	/sA0BB#c
XtD]}|j|tdtdz}|D]v}|j	|}|j||D]M}|j	|}|j|||j
|||j	||zdzOxy)Nrr)specialrmrErZrCrprs)r<rLr]r^r_rMs      r!test_bitop_identitieszLongTest.test_bitop_identitiess	-A))!,	-q)A+&	SDD!A))!,
SKK%--a3--aDKKq@P4QR
S	Sr"cg}d}|dkrd|}}|r,t||\}}|jt||r,|j|xsdg}dd|ddddd|zdj	d	|DzS)
Nrr-0b0o0x)rrcc3&K|]	}d|yw)0123456789abcdefN).0rHs  r!	<genexpr>z'LongTest.slow_format.<locals>.<genexpr>1s=)!,=s)r)r\r8reversejoin)r<rLbaser]signr/s      r!slow_formatzLongTest.slow_format%sq5!!D!T?DAqMM#a&!	A35DzDbd3D9:ww=f==>	>r"cdtfdtfdtfdtfdtffD]\}}||}|j||j5|j||}|j||ddd|j|5|jt|d|dddy#1swYCxYw#1swYxYw)Nrr}rcr~)rLmapper)gotr)
binoctstrreprhexrO__name__rrNr8)r<rLrrrexpecteds      r!check_format_1zLongTest.check_format_13sHq#hS	B:CyP	1LD&)C&//:
0++At4  h/
0#&
1  S!a0
1
1	1
0
0
1
1s%B8C8C	C
	ctD]}|j|tdD]<}tdtdzD]$}|j	|}|j|&>y)Nrcr)rurrErZrC)r<rLrHr^s    r!test_formatzLongTest.test_format<sh	#A"	#r	'Aa1-
'KK%##A&
'	'r"cddddzfg}|D]I\}}dD]?}dD]8}||z|z}|}|dk(r|tur|}	|jt||:AK|jttd|jttd	|jttd
|jttd|jttdd
|jttdd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtd dd|jttd!d|jttd"dd#d$d%d&d'd(d)d*d+d,dzd,dzg}|D]}	|jttd-|	 |jttd.y#t$rYwxYw)/N)100000000000000000000l Fx:^Ve10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000rcrd)r{+rx)r{ 	z  		  rx123L123l0Lz-37L0x32Lr~1L+000r0o123S0x123i#0b100rz	 0O123   z 0X123  z 0B100 0z+0z-00008z-012395isilllr42uこんにちは)
ValueErrorrNr8assertRaises)
r<LLsvrprefixssvv
invalid_basesrs
          r!	test_longzLongTest.test_longDs'C(

	DAq$	
7F$*BBs{q
':R((R"5
	

		
*c62*c62*c40*c62*c7B7*c44T2+	
UA*Wa"-Wa#.Wa!,[!,b1Z+S1Y*A.S!a(T1q)T1q)T1q)*c43*c9a8!5&(!5&(S&1c6'
"	;Dj#tT:	;
	
*c+KLO&sK	K$	#K$	cGdd}|jtt|Gdd}|jt5|jt|ddddy#1swYyxYw)NceZdZdZy)*LongTest.test_conversion.<locals>.JustLongcyN*rr<s r!__long__z3LongTest.test_conversion.<locals>.JustLong.__long__r"N)r
__module____qualname__rrr"r!JustLongrs
r"rceZdZdZdZy)+LongTest.test_conversion.<locals>.LongTrunccyrrrs r!rz4LongTest.test_conversion.<locals>.LongTrunc.__long__rr"cy)Nrrs r!	__trunc__z5LongTest.test_conversion.<locals>.LongTrunc.__trunc__sr"N)rrrrrrr"r!	LongTruncrs

r"rr)r	TypeErrorr8assertWarnsDeprecationWarningrN)r<rrs   r!test_conversionzLongTest.test_conversion}si			
)S(*5		

0
1	5S-t4	5	5	5s
!A44A=c	t|}	t|}dj|||}|j	|||y#t$rd}Y@wxYw#t$rd}YEwxYw)NoverflowzAError in conversion of integer {} to float.  Got {}, expected {}.)rrrformatrN)r<ractualrmsgs     r!check_float_conversionzLongTest.check_float_conversionss	 1XF	"#AH&&,fQ&A	3/	 F	 
	"!H	"s"AAA
AAAc
(gd}|D]:}|jt|||jt||<dD]K\}}tdD]8}|jttd|zd|zzd|zd|zz:MdD]K\}}tdD]8}|jttd|zd|zzd|zd|zz:Mtt}dt
z}||zdz}|jt|t|jt|dzt|jt|dz
t|j
tt||jtd|z
t|j
tt||j
tt|dz
|j
tt||j
tt|dz|j
ttd|zdz
|j
ttd|z|j
tt||ztd	D]m}d|zd
zdz}d|zdz}|jtt||d|zd
z}d|zdz}|jtt||o|dz
||dz|dz
||dz|dz
||dzd|zdz
d|z||zg}|j|tdd
D]-}tddD]}|jd|dzz|z/|D]%}	|j|	|j|	'y)N)rrrllllll)rr)rrrXrrrrbr)rr
r}rrr))rrr)rrrrr)rr}r)r}r})	r})rcr}))rr)
r)rWr~)rr~rrrdlrr}5)rNrrEr8DBL_MAXDBL_MAX_EXPrrrgr\r)
r<exact_valuesrLrMpint_dbl_max	top_powerhalfwaytest_valuesvalues
          r!test_float_conversionzLongTest.test_float_conversions	"	,AU1Xq)UA2Y+	,
M	MDAq2Y
M  U1a4q>%:!;QT57^L
M	M3	MDAq2Y
M  U1a4q>%:!;QT57^L
M	M'l{N	*Q.{+W5{1}-w7wqy)73-8qy)G84-9-	!<-	:-	!<-)A
>-)<-	)0CDs	/A1	"Q&A1	"ASq]A.1	"A1uASq]A.	/
M;A
AIw!aKIaK
iKM1Y;	)(;	
	<(r1	2A4%
2""1qt9q=1
2	2!	0E''.''/	0r"cdD]&}|jtt||(d}ddz}|}|||td}dD]}|j	t
t|| |jt|t|dy)N)gr?@X123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345ri0u)hugemhugeshuger)$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))rNrr8rrrevalassertNotEqual)r<rLrrr	namespacetests       r!test_float_overflowzLongTest.test_float_overflows*	/AU3q6]A.	/Ez!EE4P		DD 
mT4C!	D(	
E%L#e*6	8r"ctjtj}tt	dgdzD]Z}d|z}tj|}|j||||z}tj|}|j||\ddzddfD]L}|jttj||jttj|Ny)Nrc)rd'rrrr)	rlog10erYrEassertAlmostEquallogrr)r<LOG10Er.rrrr	bads        r!	test_logszLongTest.test_logssDFF#b	?%77		2C#IEJJu%E""5#.V|H((5/C""31		2%Z="a'	;Cj$((C8j$**c:	;r"cp
|j}G
fdd
gd}dD]H}|j|dz
|dz
||dz|dzt|dz
t|t|dzgJ|jddd	tjttjgtd
}|jddd	ddz|dz
||dzg|j|Dcgc]}|c}|D]}
|}|D]}
|}||kD||kz
}|j
|||5||kD||kz
}	|||	|||k(|dk(|||k7|dk7|||k|dk|||k|dk|||kD|dkD|||k\|dk\dddycc}w#1swYxYw)
Nc<eZdZdZfdZdZdZdZdZdZ	y)	)LongTest.test_mixed_compares.<locals>.Ratc$t|tr||_d|_yt|trtjt|\}}|dk(sd|cxkrdksJJd}d}|rPtj||}t|}||z	dk(sJ||z|z}||z}d|cxkrdksJJ||z}|rP|dk\r||z}d}n|}d|z}|dkr|}||_||_t	|t	|z|k(sJytd|z)Nrrr5rrzcan't deal with %r)

isinstancer8rr-rrfrexpr$rr)	r<rfrCHUNKtoprhrr-s	         r!__init__z2LongTest.test_mixed_compares.<locals>.Rat.__init__s1eS)"DFDFu-::c%j1DAq6SA^^3^3EC JJq%0 #A$~22"e|u4U
"a~#~-~-U
Av1H!GqyBDFDF 8eAh.%777#$85$@AAr"ct|s|}|j|jz|j|jz}}||kD||kz
S)N)rrr-)r<otherrLrMRats    r!_cmp__z0LongTest.test_mixed_compares.<locals>.Rat._cmp__GsL!%-JEvv'%'')91A!a%((r"c*|j|dk(SNrrr<rs  r!__eq__z0LongTest.test_mixed_compares.<locals>.Rat.__eq__L{{5)Q..r"c*|j|dk\Srrrs  r!__ge__z0LongTest.test_mixed_compares.<locals>.Rat.__ge__Nr!r"c*|j|dkDSrrrs  r!__gt__z0LongTest.test_mixed_compares.<locals>.Rat.__gt__P{{5)A--r"c*|j|dkSrrrs  r!__le__z0LongTest.test_mixed_compares.<locals>.Rat.__le__Rr!r"c*|j|dkSrrrs  r!__lt__z0LongTest.test_mixed_compares.<locals>.Rat.__lt__Tr&r"N)
rrrrrr r#r%r(r*)rsr!rrs(&
BP
)

/
/
.
/
.r"r)rgMbP?gGz?rg?g@xDZbti)gBgCg@Crg333333?rrrr+i N)rLrMRcmp)rNrgr8rmaxsizerrO)r<rPcasestrLRxrMRyr,xycmprs          @r!test_mixed_compareszLongTest.test_mixed_comparess


7	.7	.r8+	7ALL!c'1s7Aq3wCac(CFC!H6
7	7	aAs{{E#++,>?@
J
aAqEz1Q31Q378
%(Qqb()
	*AQB
*VRBG,\\A\6*Uq1u-EtUOqAvtqy)qAvtqy)q1udQh'qAvtqy)q1udQh'qAvtqy)**
*
	*)**s!
F'+A/F,,F5c
F|jtddd|jtddd|jtddd|jtddd|jtdd	d
|jtdd	d|jtdd
d|jtdd
d|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtd dd
|jtd dd
|jttd!d"dd!|jttd!d"dd#|jttd!d"dd$|jttd!d"dd%|jttd&d'|jtd&d(d)|jtd&d*d+|jtdd,d|jtd d,d
|jtdd,d-|jtdd,d.|jtdd/d-|jtdd/d.|jtdd0d1|jtdd0d.|jtdd2d3|jtdd2d.|jttd&d4|jtd&d5d6|jtdd7d8|jtd d7d9|jtdd7d:|jtdd7d;|jtdd<d:|jtdd<d;|jtdd=d>|jtdd=d;|jtdd?d@|jtdd?d;|jttd&dA|jtdBdCdD|jttddE|jttddF|jttddG|jttddH|jtdItddJ|jtdItddK|jtdItddL|jtdItddM|jtdNtddO|jtdPtddQt
tdRtdSdzDcgc]
}t|c}t
tdTtdUdzDcgc]
}t|c}zD]}|dVvs|jttdW||jttd||jttd||jttdXdYz||jttdXdYz|dZD]8}d[D]1}|jt||tt||3:ycc}wcc}w)\Ni[r-	123456789,z123,456,789_123_456_789rrx1r
z-1z-3z  1z -1z+3z +1z 3rz 1rXrL3Xi4d2i.z-4d28xz     4d2z    -4d2ber~BEz-bez-BEIz,x_x	4996_02d2_X	4996_02D2o2322z-2322z-oz oz 2322z+oz+2322z,o_o
111_4540_1322r+11z-1110011010010z-10011010010z-bz bz 10011010010z+bz+10011010010z,b90_b11_0000_0011_1001z1.3_cz,cz+czCannot specify bothz_,z,_z_,dz,_dzCannot specify ',' with 's'z,szCannot specify '_' with 's'_sr*rrAZzbcdoxXeEfFgGn%rrrdzeEfFgG%)rrr
rdrAi.i)
rNrr8rrassertRaisesRegexrEordchrr)r<rLformat_specrs    r!test__format__zLongTest.test__format__rs	3/=	3/=	3/?	3/?	
3-C$/4%0D)514%0D)514%0D)513.C$/	
3-3-c*E2s+V4d+Z8t,j9c*E2s+V4C$/C$/D"
s3T:D"
s3T:T24e<T24e<*fj$?
D1;?
D1;?	
3-C$/c*F3s+W5d+V4t,g6d+W5t,g6d+W5t,g6*fj$?
D1?C	
3.C%0c*M:s+^<d+];t,n=d+^<t,n=d+^<t,n=*fj$?t,.AB	
*fa7*fa6*fa6*fa6	
z+@&!TRz+@&!TRz+@&!USz+@&!USz+H&RSUYZz+H&RSUYZ.33s8SXaZ-HISVI-23s8SXaZ-HISVIJ	NK"22!!*faE!!*faE!!*fb+F!!*fafkJ!!*f3iM	N%	DKG
D  {!;!'ek!BD
D	DJIs0b'bc|jtttd|jtttd|jtttdy)Ninfz-infnan)rrr8rrrs r!test_nan_infzLongTest.test_nan_infsD-eEl;-eFm<*c5<8r"c|jt5ddz}ddd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jddy#1swYxYw)NrrrXr
r>rr%rNr<r7s  r!test_mod_divisionzLongTest.test_mod_divisions


0
1	AA		
!$1%2&B'#!$!$1%		sB55B>cddz}|}|j||zd|j||zd|j||zd|j||zd|jd|zd|jd|zd|jd|zd|jd|zd|jd|z|dz	z|zd|jd|z|dz	z|zd|jd|z|dz	z|zd|jd|z|dz	z|zd|j||dzzd	|jd
|z|zd
||d}dD]}|jtt|| d
D]$}t||}|j|dd|z&dD]}|jtt|| y)Nri@rrrigԄ@gԄr5i@B)rr)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)rNrrrr%)r<rrrr	underflowr0zeros        r!test_true_divisionzLongTest.test_true_divisionsEzc*,t,t,T3'T3'UC(UC(#*	2d:EB#+!4=uE#*	2e;VD#+!4<fE+S1'D.D0':!E2	7	HH
mT8YG	H
7	LI)Y/FVS>J
L	L.	HD/tYG	Hr"c|jt5ddz}ddd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jddy#1swYxYw)Nrrr
rXrrr_r`s  r!
test_floordivzLongTest.test_floordivs


0
1	QA		
#"%"%1%A&2&2&!$A&2&2&!$!		sC==Dc
b|r)tt|t|dtzkry	tt	||}	t||z}|j||dj||||y#t
$rd}YBt$rd}YNwxYw#t
$rd}YPt$rd}Y\wxYw)zVerify 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(rr1rr%rNr)r<r*r+
skip_smallrrs      r!
check_truedivzLongTest.check_truedivs#c!fc!f-<?	&GAqM*H	!q1u+C	
3)//5vaHc/J	L	"!H 	&%H	&
	C 	! C	!s/A7B7B
BBB.!
B.-B.c|jdd|jdd|jdd|jdd|jdd|jddtzzd|jdd	dttz
zz|jddd
zzd|jddd
dzzdtttttz
f}|D]}t	|dz
|dzD]h}|jddt|dzzddt|dzz|jddt|dzzddt|dzzjddd
ddd
d
zdddddddzfD]L}t	ddD];}|j|tz|z||j|tz|z|=Nt	dD]7}|jdtzdzdzddzzd|zzdtzdz9|jdd|jd d!t	d"D]8}|jd|dzzd|z|jd|zd|dzz:ddd#d
d$d%dd&dd
d
zdddddddzfD]2}t	ddD]!}|jdtz|z|z|#4t	d'd(D]}|j|dd)zd*dd
zdd"zfD]}t	d"D]}tjd|}tj|d|zdz}	|j||	|j||	|j||	|j||	t	d+D]}
tjd"}tjdd"}tjd|z}
tjdd|z}|j|
||j|
||j|
||j|
|y),N{ri8rXr>ige~rrLiNFrdíl90r
Qri0&iCrr
rii)2rci
lE,J_lJbrrr}r~ ii4ld(	r)	rkrr(r'rErr&r9	randrange)r<basesrr.mrrHMr*r+r7a_bitsb_bitsrLrMs               r!$test_correctly_rounded_true_divisionz-LongTest.test_correctly_rounded_true_division9s	
3"4#1a 1b!1a ;K7?5&1|k/I+J"JK5C</;ae4L+kL8:	PDTBYr	2
P""5CQK#7q#sdA,9NO""5CQK#7q#sdA,9NO
P	PQ2uafb"c6BF74	?A3^
?""1%5#5#91=""1%5#5#9A2>
?	?s	2A
<! 3U:1c6AAqDHl?50
2
	2	
1d#	
02GHt	1ArAaCy"a%0r1ub1Q3i0	1
Q1aRUAsFb"c6BF74	=A3^
=""1l?1#4q#8!<
=	=sB	+Aq!T'*	+"c'2t8,	+A4[
+$$Q*$$Q!A.""1a(""A2q)""1qb)""A2r*

+	+u	'A%%d+F%%a.F  F+A  AvI.Aq!$q1"%r1%rA2&	'r"c|jt5ddzddd|jt5dddzzddd|jt5ddz	ddd|jt5dddzz	dddy#1swY{xYw#1swY`xYw#1swYIxYw#1swYyxYw)Nrr>rr)rrrs r!test_negative_shift_countz"LongTest.test_negative_shift_counts


z
*	"H	


z
*	AI,	


z
*	"H	


z
*	AI,		
								s.B
B" B.
B:B"B+.B7:Cc@|jdd|jdd|jt5ddzddd|jdddzzd|jt5dddzzdddy#1swYIxYw#1swYyxYw)Nrr
rr)rNrrrs r!test_lshift_of_zerozLongTest.test_lshift_of_zeros#!$


z
*	
G	qDy)1-


z
*	
19						sB5
BBBc|jdtjzd|jdtjdzzdy)NrrrNrr-rs r!test_huge_lshift_of_zeroz!LongTest.test_huge_lshift_of_zeros:
	
ckk)1-s{{Q/3r"rg?F)memusedry_runcx|jdtjdzzddztjzy)Nrrr)r<sizes  r!test_huge_lshiftzLongTest.test_huge_lshifts/	
s{{T12AI4LMr"cddz}|jd|z	d|jd|z	d|jd|z	d|jd|z	d|jd	d
z|z	d|jd	d
z|z	dy)Nrrrrir
icirrrN)r<
huge_shifts  r!test_huge_rshiftzLongTest.test_huge_rshifts$Y
z)1-#*,b1+Q/%J.3C:-q1!S&J.3r"g?cddzdztjz}|j|tjdzz	ddzdz|j|tjdzz	dy)Nrrrirbrr)rr-rN)r<rrs   r!test_huge_rshift_of_hugez!LongTest.test_huge_rshift_of_huges]cRCKK/#++/2Q#XNC#++"45q9r"c|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jddzd	z	dd
z|jddzd	z	dd
z|jddzd	zd	z	dd
z|jddzd	zd	z	dd
zd	z
y)Nriii1iirrrrrs r!test_small_rshiftzLongTest.test_small_rshifts"%S)"%S)C(t,C(t,C1af-!S&A3w/!S&1**AsF31c6A:!+afWq[9r"c|jdd|jdd|jdd|jdd|jddzdz	ddz|jddzdz	ddz|jdttzz
tz	t|jtdz
ttzz
tz	ty)	Nrr
rr>rrwr)rNBASEr7rs r!test_medium_rshiftzLongTest.test_medium_rshifts!$R(A&r*C1af-!S&A3w/	
!d4i-E1D59$(T$Y.584%@r"c|jdd|jdd|jdd|jdd|jddzdz	ddz|jddzdz	ddzy)Nrr
rrrv`rrs r!test_big_rshiftzLongTest.test_big_rshifts~1%b)Q'+C2q"u-!S&BB/r"c|jdd|jdd|jdd|jdd|jddzdzddz|jddzdzddzy)	NTiibirrrrrrs r!test_small_lshiftzLongTest.test_small_lshifts~"%S)4(e,C1af-!S&A3w/r"c|jdd|jdd|jdd|jddy)NiTiii<rrs r!test_medium_lshiftzLongTest.test_medium_lshiftsB%(V,F+w/r"c|jdd|jdd|jdd|jdd|jddzdzddz|jddzdzddzy)	Nllllrrrvrrs r!test_big_lshiftzLongTest.test_big_lshifts~:.k2\2
6C2q#v.!S&BC0r"cxddz}|dz}|dz}|j||zd|j||z
dy)Nrrdr)assertIs)r<r*r+cs    r!#test_small_ints_in_huge_calculationz,LongTest.test_small_ints_in_huge_calculationsC
H
BF
E

a!eQ

a!eQr"c|jtdddd|jddd\}}}|j||z|zd|jtdddd|jddd	\}}}|j||z|zd|jtdd
dd
zdz
d|jdd
zdd
zdz
zddd
dd
zdz
}}}|j||z|zdy)NrcrXr)rcrXrrr)rrrrd)rpow)r<r*rrzs    r!test_pow_uses_cached_small_intsz(LongTest.test_pow_uses_cached_small_intss

c"aoq)

mQ'1a

a1fqj!$

c!R-q1

-q1$1a

a1fqj!$

c!S!S&1*-q1

a3h!s(Q,/3S!S&1*a1

a1fqj!$r"cddz}|j|dz|zd|j|dz|zd|j||dzzd|j||dzzdtd|zdz|\}}|j|d|j|dtd|zdz|\}}|j|d|j|dtd|zdz
|\}}|j|d|j|dtd|zdz
|\}}|j|d|j|dy)	NrcrdrrrrXr
r>)rr))r<bigr r/s    r!"test_divmod_uses_cached_small_intsz+LongTest.test_divmod_uses_cached_small_intss<Ci

sQw#oq)

sQw3&*

ccQh'+

ccRi("-a#gk3'1

a

ab3hnc*1

a

aaC4j1nsd+1

a

aa#gkC4(1

a

ar"c	tddD]}|j||dz|j||dz|j||dz
|j||dz|j||dz|j||dz|j||dz|j|||j||dz|j|tt||j||dzdz	t|d}|j||z
d|jd|zdy)Nrprrr
rl)rErr8r)r<rHs  r!test_small_intszLongTest.test_small_ints1sr3	.AMM!QU#MM!QU#MM!QU#MM!Q!V$MM!QV$MM!QU#MM!QU#MM!qbS!MM!QT"MM!SQ[)MM!QT1Wc!f-	.


a!eQ

a!eQr"cd}tddD]}|j}|j|tt	|jd|dk7r2|j
d|dz
zt|cxkxrd|zkncn|j|d|dk7s|j|dtjtjt|tjdz|zz|jdjd|jdjd|jdjd|jdjd|jd	jdd
D]}d|z}|j|dz
j||jd|z
j||j|j|dz|j|j|dz|j|dzj|dz|j|dz
j|dzy)Ng|=iiz-0brrrr
r)rrXrr~rorrv!?@)rErrNlenrlstripr;r$rfloorr	)r<tinyrLkrHr*s      r!test_bit_lengthzLongTest.test_bit_lengthCsvu%	>AAQCFMM%$8 9:AvAaCCF 9QT 9:  A&Av
  A

Q(!4t;)=%=>	>$	
!)1-!)1-"*A.!)1-"*A.<	7A1Aac--/3ac--/3a^^-qs3qb__.!4ac--/15qbd..0!A#6	7r"ctddD]:}|j|jt|j	d<dD]}d|z}|j|jd|j|dz
j||j|dzjd|j|dz
d	zj|d
z
y)Nirr9)rcrorrAiiZirrrr
ir})rErN	bit_countrcount)r<r*r.s   r!test_bit_countzLongTest.test_bit_countesud#	?AQ[[]CFLL,=>	?>	CC3AQ[[]A.a!e..0#6a"f//115q1um668#'B	Cr"c
iddddddddddddddd	dd
dddddddd
ddddddddddddd}tdddD]_}|jD]J\}}t||zd}||z}|j|||j	t|tLa|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtddd|jtd dd|jtd!dd"|jtd#dd"|jtd$dd%|jtd&dd%|jtd'dd(|jtd)d*d+|jtd,d*d-|jtd.dd/|jtd.dd0|jtd.d*d1|jtd.d2d3|jtd.d4d5|jtd.d6d7|jtd.d8d9|jtd.d:d;|jtd.d<d=|jtd.d>d?|jtd.d@d|jtd.dAd|jtd.dBdtdd"D]M}td|zdCzd*}d|zdDz}|j|||j	t|tOtdD]e}td"D]U}	tjdEdF}
t|
|}|j||
|j	t|tWgdGdHdIdJdd"zdd"zfD]}|jtdK|dK td"D]T}	tjdEdF}
t|
}|j||
|j	t|tVdL}|D]}
|jttd|
 y)MNrrrrXrrbrrcr
r}rrrrrWrrwr~)roiir
ijri8ikrSiii1rr3rdrurti,iԡr>iiil!l!l~!l!rl!rpl`!il!r^l'!ilz+ilv|orsl,GxiiiiFiirrrrri{)brianry)rEitemsroundrNrtyper8r9rxrr)r<	test_dictoffsetrrrrexpectrrHrLhuge_n
bad_exponentsrs              r!
test_roundzLongTest.test_roundpsG8Qq8!A8q8Aa818a8r8R8!"28'(8-/846r8;=b8BDR8IKB88r8&(RB8	D#r*	.F!)
.1AfHb)V8  h/

d3i-	
.	.	
tR$/tR$/sB.sB+sB+r2*q"q)q"q)r2*r2*r2,sB-sB-sB-sB-vr*F3vr*F3{B/={B/={B/={B/={B/={B/={B/={B/={B/={C0+>{C0!4{C0!4{D115r3	*AA+CUV^FS&)MM$s)S)		*q	.A3Z
.$$VU3Aqk  a(

d3i-	
.	.uguafb#gE	>FU7F3W=	>s	*A  /A(CS!$MM$s)S)		*+
	6Ai15	6r"c8d=fd	}iddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$}||d%d&'iddddddd	d
ddd
ddddd(dd)dddddd*dddd+dd,d!d-d#d.}||d/d&'dddddddd0d1d2d3
}||d%d'dddddd*dd+d1d4d3
}||d/d'jtdjdd%d'jtdjdd%d&'jtdjdd/d'jtdjdd/d&'jtdjd5d%d'jtdjd5d/d'jdjdd%d6jdjd7d%d8jdjd7d%d9jdjd7d%d&'d:jtdjdd%Gd;d<t}jdjd|d%djdjd|d/d6y)>NFc	bdd}|jD]\}}	j|jt||||t|dk(r(|dk(r#|s!	j|j|	j||t||||y#t$r"}tdj
||||d}~wwxYw#t$r }tdj
||d}~wwxYw#t$r"}tdj
||||d}~wwxYw)	Nc|dk(rt|}n|dk(rtt|}tfdDS)Nlittlerc34K|]}|dzz	dzyw)r}Nr)rrHrs  r!rzSLongTest.test_to_bytes.<locals>.check.<locals>.equivalent_python.<locals>.<genexpr>s>1a1Q3h$.>s)rEreversedbytes)rlength	byteordersignedorders`    r!equivalent_pythonz@LongTest.test_to_bytes.<locals>.check.<locals>.equivalent_pythons;(!&ME%'$U6]3E>>>>r"rz4failed 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)rrNto_bytesr	ExceptionAssertionErrorrtestsrrrrrerrr<s       r!checkz%LongTest.test_to_bytes.<locals>.checksP
?#(++-
OhC$$

c(mYv
N "x=A%)u*<V4(((C
O$$) #h-6K )
O
!C(Ni8:?BCC%4,I#VD\+0344!O(%%+VD)V%DFLOOOsG-B)  C%D)	C2CC	D C;;D	D.D))D.rrr
rrrsrTrr)
rrrrrrrrrr"rbsssceZdZy)&LongTest.test_to_bytes.<locals>.SubStrNrrrrr"r!SubStrr:r"rr)rrrrNr)r<rtests1tests2tests3tests4rs`      r!
test_to_byteszLongTest.test_to_bytess%	OP

w

w



'	


'

+






+

+





;

O

?
 
O!
"
o#
&	feD)

w

w



'	


'

+






+

+





;

K

?
 
O!
"
o#
&	fht,"
	feE*"
	fhu--#E%P-#E$O-#HUS-#HTR-"5O-"8ER!a/5!a/1HI!a/1HI"q%=0	2-!q%@	S	!a7A!a)9:C@r"c
dMfd	}iddddddddd	dd
dddd
ddddddddddddddddddd d!d"d#d$d%}||d&d'(iddddddddd	dd
dddd
dddddddd)dd*dddddd	ddd d!d"d#d$d+}||d,d'(ddddd-ddd d.d"d/d0}||d&d(ddddd-ddd d.d"d/d1}||d,d(Gd2d3t}jt|jdd&|j	|jdd&djt|jdd&d(|j	|jdd&d(djt|jdd,|j	|jdd,djt|jdd,d(|j	|jdd,d(dj	tjgd4d&d'(d#j	tjd4d&d'(d#j	tjtd5d&d'(d#j	tjtd5d&d'(d#j	tjt
jd6d5d&d'(d#j	tjtd5d&d'(d#jttjdgd&jttjdgd7jttjdgd8jttjd9d&jttjd:d&jttjdd&jttjdd&d'jt|jd9d&jt|jd:d&jt|jdd&jttjdd&d'Gd;d<t}|jdd&}jt||j	|d=Gd>d?t}	|	jdd&}jt||	j	|dj	t|d@dAdBGdCdD}
GdEdF}GdGdH}GdIdJ}
j	tj|
djttj|jttj|jttj|
GdKdLt}j	tjd|d&dj	tjd|d,dy)NNFc	2dd}|jD]w\}}	jtj|||||dk(r(|s&	jtj||	j|||||yy#t$r"}tdj
||||d}~wwxYw#t$r }tdj
||d}~wwxYw#t$r"}tdj
||||d}~wwxYw)Nc|dk(rt|}n|dk(rtt|}tdtD}|r|r|ddzr|ddt	|zzz}|S)Nrrc32K|]\}}||dzzyw)r}Nr)rrHr+s   r!rzULongTest.test_from_bytes.<locals>.check.<locals>.equivalent_python.<locals>.<genexpr>GsGTQQqSGsr
rrr})rYrsum	enumerater)
byte_arrayrrlittle_orderedrs     r!rzBLongTest.test_from_bytes.<locals>.check.<locals>.equivalent_pythonAso(%)*%5N%'%)(:*>%?NGY~-FGGn.2Dt2KaN 3333Ar"rz6failed to convert {} with byteorder={!r} and signed={}rrzeCode equivalent from docs is not equivalent for conversion of {0} with byteorder={1!r} and signed={2}r)rrNr8
from_bytesrrrrs       r!rz'LongTest.test_from_bytes.<locals>.check@s>

#(++-
ChC$$tYvF "%f4((NN40$&	C$$)$	&I -
C
!C(Pi8:?BCC%4,I#VD\+0344!C(Pi8:@CCCsG(B
%B?3C+	B<B77B<?	C(C##C(+	D4DDr"rrsrrr	rr
rrrrrrrrrrrrrrrrrrrrrrrrr)rrrrrTrrr)r
rrr
rrrr)r"rrrrrrrrrr)r"rrrrrr	rr
rrceZdZy)'LongTest.test_from_bytes.<locals>.myintNrrr"r!myintr(rr"r))rrrrBzbigzlittler{ceZdZdZy)(LongTest.test_from_bytes.<locals>.myint2c4tj||dzS)Nr)r8__new__)clsrs  r!r/z0LongTest.test_from_bytes.<locals>.myint2.__new__s{{3	22r"Nrrrr/rr"r!myint2r-s
3r"r2rceZdZdZy)(LongTest.test_from_bytes.<locals>.myint3cd|_y)Nbar)foo)r<rs  r!rz1LongTest.test_from_bytes.<locals>.myint3.__init__s	 r"N)rrrrrr"r!myint3r4s
!r"r8r7noner6ceZdZdZy),LongTest.test_from_bytes.<locals>.ValidBytescy)Nrrrs r!	__bytes__z6LongTest.test_from_bytes.<locals>.ValidBytes.__bytes__sr"Nrrrr=rr"r!
ValidBytesr;s
r"r?ceZdZdZy).LongTest.test_from_bytes.<locals>.InvalidBytescy)Nabcrrs r!r=z8LongTest.test_from_bytes.<locals>.InvalidBytes.__bytes__sr"Nr>rr"r!InvalidBytesrAs
r"rDceZdZy).LongTest.test_from_bytes.<locals>.MissingBytesNrrr"r!MissingBytesrFsr"rGceZdZdZy).LongTest.test_from_bytes.<locals>.RaisingBytescddzy)Nrrrrs r!r=z8LongTest.test_from_bytes.<locals>.RaisingBytes.__bytes__s	Ar"Nr>rr"r!RaisingBytesrIs
r"rKceZdZy)(LongTest.test_from_bytes.<locals>.SubStrNrrr"r!rrMrr"rr)r8rrr&rN	bytearrayarray
memoryviewrrrgetattrr%r)r<rrrrrr)r2rHr8r?rDrGrKrs`              r!test_from_byteszLongTest.test_from_bytes?s+	C\

Q



Q	




R




T

T



S








 
!
"
#
$ "#%+
.	feD)

Q



Q	




R




T

T



S








 
!
"
#
$ "#%+
.	fht,"
	feE*"
	fhu-	C		


d5++GU;<eD))'591=

!!'5!?@%	I))'5)GK

d5++GX>?G))'8<a@

d5++Xe,-./4	6))'8E)JANNN;dN;V	ENN;dN;V	Eo&d(<=C	Eo&d(<=C	EKK_-uT(CDJ	L't(=>D	F*cnnseUC*cnnqc9E*cnnqc<H)S^^R?)S^^VUC)S^^Q>)S^^QtD)U%5%5r5A)U%5%5vuE)U%5%5q%@)S^^QtD	3S	3
gu-

d1gv&A	!S	!
gu-

d1gv&AE62E:					 			

5q9)S^^\^D)S^^\^D+S^^\^L	S	VE];Q?1ABAFr"ctddD]<}|jdd}|jtj	|d|>y)NrprrTr)rErrr8r&)r<rHr+s   r!test_from_bytes_smallzLongTest.test_from_bytes_small
sFr3	=A

1T
*AMM#..4.8!<	=r"c|jdj|jdj|jdjy)Nr
rr)r;
is_integerrs r!test_is_integerzLongTest.test_is_integers;)*()()r"cGddt}tdDcgc]
}|d}}tt|D]}|j|dycc}w)NceZdZddZy)<LongTest.test_access_to_nonexistent_digit_0.<locals>.Integerc@tj||}d|_|S)Nr7)r8r/r7)r0rr<s   r!r/zDLongTest.test_access_to_nonexistent_digit_0.<locals>.Integer.__new__s{{3. r"N)rr1rr"r!IntegerrZs
r"r\rr)r8rEmaprN)r<r\rHintegersrs     r!"test_access_to_nonexistent_digit_0z+LongTest.test_access_to_nonexistent_digit_0sV	c	).d41GAJ44S(#	#AQ"	#5sAcdD]M}dD]F}|jt||zt|jt||z	tHOy)N)TF)rr)rNrr8)r<rrs   r!test_shift_boolzLongTest.test_shift_bool'sR"	<E
<  eun!5s;  eun!5s;
<	<r"c
RGddt}ddddtjdzdd|d	g}|D]r}|j\}}|j	||ft|df|j	t|t|j	t|tty)
NceZdZy)-LongTest.test_as_integer_ratio.<locals>.myintNrrr"r!r)rd/rr"r)rcrrsrTFr)r8rr-as_integer_ratiorNr)r<r)rr	numeratordenominators      r!test_as_integer_ratiozLongTest.test_as_integer_ratio.s	C	QQaueBiH	5E%*%;%;%="I{i5E
AGT)_c2T+.4		5r"c	tddD]M}d|zdz
}|j||5|j|dzdd|zzd|dzzz
dzdddOy#1swYZxYw)Nri)bitlenrr)rErOrN)r<rjrs   r!test_squarezLongTest.test_square8s
Asm	CFf!AVq1
C  A1v:&1!+<=AC
C
C	C
C
Cs(AA'	c
N|jtjtjj
dddtdz
dfdtz
dftdftdfttzdz
dfttzdfg	}|D]a\}}|j|5|j|jtjtj|zzdddcGddt}|j|jtjj
|D]_\}}|j|5|j||j|j|j|zzddday#1swYxYw#1swYyxYw)	N)rr)rr)r
rrrrXceZdZy)'LongTest.test___sizeof__.<locals>.MyIntNrrr"r!MyIntrn^rr"ro)
rNr8__itemsize__rint_infosizeof_digitrrO
__sizeof__
__basicsize__)r<rrr=ros     r!test___sizeof__zLongTest.test___sizeof__Ds))3<<+D+DE

!VQK
tVQK
1IUAJ
$Y]A
$YN
*	NE7e$
  $$&%%(8(87(BB

		C		
++S\\-F-FG)	NE7e$
  %L++-''%*<*<w*FF

	



sAFAFF	F$	N)T)?rrrrCrIrUr`rirmrprsrvrrrrrrrrequires_IEEE_754rrrr3rXr\rarergrkr~rrcpython_onlyr
bigmemtestrr-rrrrrrrrrrrrrrrrrrRrTrWr_rarhrkrurr"r!r3r3ss40
C#>N+.+6+/
S>1'6Mr5"0"
C0C0J8>;$Z*x_DB9
& HD%&L<
Y'Y'v
44
Wd*8UKNLN4
Wc)$F:G:
: 
A0001
  
%% 
0 $ 7D	CH6TCAJLG\
==*
#<5
C$r"r3__main__)#unittestrrrr9rrOrqbits_per_digitr7rrGr[rZrurlrErHr\rrrrrmin_expr'rr(r&rr1TestCaser3rmainrks0r!<module>rsc

	##Ezax
	
aD$!)%79K
L	qwANN26	qB 1QB #81QB#888

..

nn$$nn$$~~&&k>Al(BQ(F$GG*'\+<ux  up/zHMMO]2!#8s<
D9
D>