Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_strtod.cpython-34.pyc

�
f frP�@s�ddlZddlZddlZddlZddlZeedd�dkrfejd��nejdej	ej
B�jZddd	d
d�Z
dZGd
d�dej�Zdd�Zedkr�e�ndS)�N�float_repr_style�ZshortzHcorrectly-rounded string->float conversions not available on this systemam    # A numeric string consists of:
    (?P<sign>[-+])?          # an optional sign, followed by
    (?=\d|\.\d)              # a number with at least one digit
    (?P<int>\d*)             # having a (possibly empty) integer part
    (?:\.(?P<frac>\d*))?     # followed by an optional fractional part
    (?:E(?P<exp>[-+]?\d+))?  # and an optional exponent
    \Z
�5i�icCs�t|�}|dkr'td��n|jd�p9d}t|jd�|�}t|jd�pjd�t|�}|jd�d	k}|d
t|d�d
td|�}	}
|	s�|r�dSd
S|	j�|
j�}||dkr�|	|?n|	|>|
k7}t||�|}|	t|d�>|
t|d�>}	}
t|	|
�\}
}d||
ks�d||
kr�|
d@r�|
d7}
|
j�|dkr�|
d}
|d7}q�n|
j�|kr�|||ks�t�|
j�|ks|||kst�||
j�|kr8|r4dSdS|
sL|rHdSd
Sd|dd}d|dd}|
|>||}
}dj	|r�d	nd|
d||
d|||d|�S)z�Convert a finite decimal string to a hex string representing an
    IEEE 754 binary64 float.  Return 'inf' or '-inf' on overflow.
    This function makes no use of floating-point arithmetic at any
    stage.Nzinvalid numeric stringZfracr�int�exp�0Zsign�-�
rz	-0x0.0p+0z0x0.0p+0��z-inf�inf��z{}0x{:x}.{:0{}x}p{:+d}�)
�
strtod_parser�
ValueError�groupr�len�max�
bit_length�divmod�AssertionError�format)�s�mant_dig�min_exp�max_exp�mZfractionZintpartrZnegative�a�b�d�e�q�rZhexdigsZshift�r$�5/opt/alt/python34/lib64/python3.4/test/test_strtod.py�strtodsF%,+(*

((r&r	c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
jjde
jj
ddddd�dd��Zdd�Zdd�ZdS)�StrtodTestscCs�yt|�}WnEtk
r@|ddkr6dnd}Yn$tk
rWd}Yn
X|j�}t|�}|j||dj|||��dS)z�Compare the result of Python's builtin correctly rounded
        string->float conversion (using float) to a pure Python
        correctly rounded string->float implementation.  Fail if the
        two methods give different results.rrz-infrzmemory errorzEIncorrectly rounded str->float conversion for {}: expected {}, got {}N)�float�
OverflowError�MemoryError�hexr&�assertEqualr)�selfrZfsZgotZexpectedr$r$r%�check_strtodWs
 
zStrtodTests.check_strtodc
Cs�x�dD]�}dd|}dd|}|ddkrH|d	7}nx\tt�D]N}tj||d�|}}x)|ddkr�|d|d	}}qzW|ddks�t�||}}x`|dkr(d
j||�}	|j|	�d
j|d|d�}	|j|	�|d9}q�W||}}xj|dkr�d
j||�}	|j|	�d
j|d|d�}	|j|	�|d9}|d	8}q9WqUWqWdS)Nr�r	��r
�6rrr��	z{}e{}�()rr/r	r0r1ll����ll����)rrr3r4l F�x:^Vl	�O�z��p�cl F�x:^Vl	�O�z��p�c)�range�	TEST_SIZE�random�	randrangerrr.)
r-�k�upper�lower�i�nr!�digits�exponentrr$r$r%�test_short_halfway_casesjs2








z$StrtodTests.test_short_halfway_casescCs�x�tdt�D]�}tjd�}t|d�\}}|rY|d
|d}}n|d8}d|d|d}}|dkr�||>}d}n|d|}|}d	j||�}|j|�qWdS)N�di�r
�4ri2rr/z{}e{}l�l�l�l�)r6r7r8r9rrr.)r-r=�bitsr!rr?r@rr$r$r%�test_halfway_cases�s

	zStrtodTests.test_halfway_casesc	Cs�ddddg}x�|D]�\}}}xutd�D]g}|tjd|d|�}|}d
j||�}|j|�|d9}|d9}|d8}q5WqWdS)N��9V��V�%o�$C�K�!����jT&iG�Mri�rz{}e{}r	r���)rFrNrH)rIrJrK���)rLrOrM���)rrPrM���)r6r8r9rr.)	r-Z
boundariesr>r!�u�jr?r@rr$r$r%�test_boundaries�s	


zStrtodTests.test_boundariescCsyxrtdd	�D]a}d|d
}xItt�D];}|tjdd�}dj||�}|j|�q2WqWdS)Ni�i@r	r
i3i�z{}e{}ip���i����lHi���)r6r7r8r9rr.)r-r@�baserSr?rr$r$r%�test_underflow_boundary�sz#StrtodTests.test_underflow_boundarycCszxsdD]k}d|}xXtdt�D]F}tj|�}tjdd
�}dj||�}|j|�q(WqWdS)Nr/r	�r0r��rGr1r5�)�2i�z{}e{})r/r	rWr0rrXrYrGr1r5rZr[ip���)r6r7r8r9rr.)r-ZndigsZdig10r=r?r@rr$r$r%�test_bigcomp�s

zStrtodTests.test_bigcompc
s�d�d}x�td�D]�}x�tt�D]�}tj|�}tjd�}|dj�fdd�t|�D��7}tjd	d
g�r�|d7}tjd�}|dj�fdd�t|�D��7}nd
}tjd	d
g�ra|tjddg�7}|tj|�7}tjdd�}|dj�fdd�t|�D��7}n||r{|j|�q,yt|�Wntk
r�Yq,Xd
s,t	d��q,WqWdS)NZ000000123456789�+rri�r/c3s|]}tj��VqdS)N)r8�choice)�.0�_)r?r$r%�	<genexpr>�sz+StrtodTests.test_parsing.<locals>.<genexpr>TF�.c3s|]}tj��VqdS)N)r8r^)r_r`)r?r$r%ra�srr!�Err
c3s|]}tj��VqdS)N)r8r^)r_r`)r?r$r%ra�szexpected ValueError)r]rr)
r6r7r8r^r9�joinr.r(rr)r-Zsignsr=rSrZintpart_lenZfracpart_lenZexponent_lenr$)r?r%�test_parsing�s4,


zStrtodTests.test_parsing�sizer	ZmemuserZdry_runFcCsjdd|}|jt��t|�WdQX~dd|d}|jt��t|�WdQX~dS)Nz1.�1z0.r)ZassertRaisesrr()r-�maxsizerr$r$r%�test_oversized_digit_strings�sz(StrtodTests.test_oversized_digit_stringscCs�dd�}dd�}|jt|d��d�|jt|d��d�|jt|d��d�|jt|d��d�|jt|d��d�|jt|d��d�dS)	NcSsdjd|d|�S)z* Long string with value 1.0 and exponent nz	0.{}1e+{}rr)r)r>r$r$r%�positive_expsz6StrtodTests.test_large_exponents.<locals>.positive_expcSsdjd||�S)z+ Long string with value 1.0 and exponent -nz1{}e-{}r)r)r>r$r$r%�negative_expsz6StrtodTests.test_large_exponents.<locals>.negative_expi'g�?i Ni0u)r,r()r-rjrkr$r$r%�test_large_exponentssz StrtodTests.test_large_exponentsc,Cs�ddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g,}x|D]}|j|�q�WdS)-Nz02183167012312112312312.23538020374420446192e-370z712579816049008305546974391768996369464963024663104e-357z717489628565202117263145367596028389348922981857013e-357z718487398785991994634182916638542680759613590482273e-357z732002864200581033134358724675198044527469366773928e-358z794393431193180696942841837085033647913224148539854e-358z773608278998966969345824653500136787876436005957953e-358z764774478836417299491718435234611299336288082136054e-358z713704940134126574534878641876947980878824688451169e-357z746697445774047060960624497964425416610480524760471e-358z728639097178261763178489759107321392745108491825303e-311z1.00000000000000001e44z-1.0000000000000000100000000000000000000001e44z399999999999999994487665465554760717039532578546e-47Zo9654371763336549317990355136719971183455700459144696213413350821416312194420007991306908470147322020121018368e0a104308485241983990666713401708072175773165034278685682646111762292409330928739751702404658197872319129036519947435319418387839758990478549477777586673075945844895981012024387992135617064532141489278815239849108105951619997829153633535314849999674266169258928940692239684771590065027025835804863585454872499320500023126142553932654370362024104462255244034053203998964360882487378334860197725139151265590832887433736189468858614521708567646743455601905935595381852723723645799866672558576993978025033590728687206296379801363024094048327273913079612469982585674824156000783167963081616214710691759864332339239688734656548790656486646106983450809073750535624894296242072010195710276073042036425579852459556183541199012652571123898996574563824424330960027873516082763671875e-1075z247032822920623295e-341z799037485700245683102805043437346965248029601286431e-373z799617639833743863161109961162881027406769510558457e-373z798852915025769345295749278351563179840130565591462e-372z799059944827693569659153042769690930905148015876788e-373z798914979205069368270421829889078356254059760327101e-372z,1000000000000000000000000000000000000000e-16z-10000000000000000000000000000000000000000e-17z=991633793189150720000000000000000000000000000000000000000e-33z;4106250198039490000000000000000000000000000000000000000e-38z*10.900000000000000012345678912345678912345a11651287494059419563861790709256988151903479322938522856916519154189084656466977171489691608488398792047332126810029685763620092606534076968286334920536334924763766067178320990794927368304039797998410780646182269333271282839761794603623958163297658510063352026077076106072540390412314438457161207373275477458821194440646557259102208197382844892733860255628785183174541939743301249188486945446244053689504749943655197464973191717009938776287102040358299419343976193341216682148401588363162253931420379903449798213003874174172790742957567330246138038659650118748200625752770984217933648838167281879845022933912352785884444833681591202045229462491699354638895656152216187535257259042082360747878839946016222830869374205287663441403533948204085390898399055004119873046875e-1075a^5254406533529552661096610603582028195612589849649138922565278497589560452182570597137658742514361936194432482059988700016338656575174473559922258529459120166686600002102838072098506622244175047522649953606315120077538558010753730576321577387528008403025962370502479105305382500086822727836607781816280407336531214924364088126680234780012085291903592543223403975751852488447885154107229587846409265285440430901153525136408849880173424692750069991045196209464308187671479664954854065777039726878381767789934729895619590000470366389383963331466851379030183764964083197053338684769252973171365139701890736933147103189912528110505014483268752328506004517760913030437151571912928276140468769502257147431182910347804663250851413437345649151934269945872064326973371182115272789687312946393533547747886024677951678751174816604738791256853675690543663283782215866825e-1180Z32602129298404963083833853479113577253105939995688e2Z5260212929840496308383385347911357725310593999568896e0z826021292984049630838338534791135772531059399956889601e-2Z5260212929840496308383385347911357725310593999568895e0Z5260212929840496308383385347911357725310593999568897e0Z5260212929840496308383385347911357725310593999568996e0Z5260212929840496308383385347911357725310593999568866e0z9007199254740992.00A5179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792a9179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791.999a9179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792.001z:999999999999999944488848768742172978818416595458984375e-54zA9999999999999999444888487687421729788184165954589843749999999e-54zA9999999999999999444888487687421729788184165954589843750000001e-54z�0.000000000000000000000000000000000000000010000000000000000057612911342378542997169042119121403423543508714776317814976295686899169228986994124665807319451982237978882039897143840789794921875)r.)r-Ztest_stringsrr$r$r%�test_particulars\	
zStrtodTests.test_particularN)�__name__�
__module__�__qualname__r.rArErTrVr\re�test�supportZ
bigmemtestZ_2Grirlrmr$r$r$r%r'Vs+	$7
r'cCstjjt�dS)N)rqrrZrun_unittestr'r$r$r$r%�	test_main�srs�__main__)r8Zunittest�re�sysZtest.supportrq�getattrZSkipTest�compile�VERBOSE�
IGNORECASE�matchrr&r7ZTestCaser'rsrnr$r$r$r%�<module>s9�[