HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_sort.cpython-37.pyc
B

��g�5�@s�ddlmZddlZddlZddlmZejZdaddd�ZGdd�dej	�Z
Gdd	�d	ej	�ZGd
d�dej	�Zdd
�Z
Gdd�dej	�Zedkr�e��dS)�)�supportN)�
cmp_to_keycCs�trtd|�|dd�}|r0|jt|�d�n|��t|�t|�kr�td|�tdt|�t|��t|�t|�t|�td7adSx`t|�D]T\}}||}||k	r�td|�td|||�t|�t|�t|�td7adSq�WdS)Nz    checking)�keyzerror inzlength mismatch;�zout of order at index)�verbose�print�sortr�len�nerrors�	enumerate)�tagZexpected�rawZcompareZorig�iZgood�maybe�r�*/usr/local/lib/python3.7/test/test_sort.py�check
s0


rc@seZdZdd�ZdS)�TestBasec
	sXdg}x2tdd�D]$}d|}|�t|d|d��qW|�dddg�G�fdd�dt��Gd	d
�d
t���x�|D�]�}tt|��}tr�td|�|dd�}td||�|dd�}|��td
||�|dd�}t�	|�td||�|dd�}|��|dd�}td||dd��t�r8td�td�|dd�}|j
tdd��d�td||�t|�dk�r�dd�}|dd�}|j
t|j
|d��fdd�|D�}|dd�}t�	|�d�_d}y|�
�Wntk
�r�d}YnX|�r
d�_td||��fdd�t|�D�}dd�|D�}	|	�
�d d�|	D�}td!||�qvWdS)"Nrr�
��di�cs,eZdZdZdd�Z�fdd�Zdd�ZdS)	z+TestBase.testStressfully.<locals>.ComplainsTcSs
||_dS)N)r)�selfrrrr�__init__6sz4TestBase.testStressfully.<locals>.Complains.__init__cs2�jr&t��dkr&tr"td||�t�|j|jkS)Ng����MbP?z        complaining at)�maybe_complain�randomrr�RuntimeErrorr)r�other)�	Complainsrr�__lt__9s
z2TestBase.testStressfully.<locals>.Complains.__lt__cSs
d|jS)Nz
Complains(%d))r)rrrr�__repr__@sz4TestBase.testStressfully.<locals>.Complains.__repr__N)�__name__�
__module__�__qualname__rrrrr)rrrr3src@s$eZdZdd�Zdd�Zdd�ZdS)z(TestBase.testStressfully.<locals>.StablecSs||_||_dS)N)r�index)rrrrrrrDsz1TestBase.testStressfully.<locals>.Stable.__init__cSs|j|jkS)N)r)rrrrrrHsz/TestBase.testStressfully.<locals>.Stable.__lt__cSsd|j|jfS)NzStable(%d, %d))rr#)rrrrrKsz1TestBase.testStressfully.<locals>.Stable.__repr__N)r r!r"rrrrrrr�StableCsr$zTesting size�identity�reversedzrandom permutationzreversed via functioncSs||k||kS)Nr)�a�brrr�<lambda>a�z*TestBase.testStressfully.<locals>.<lambda>z3    Checking against an insane comparison function.z?        If the implementation isn't careful, this may segfault.cSstt��d�dS)N�r)�intr)r'r(rrrr)gr*)rz(an insane function left some permutationcSst�dS)N)r)�xrrr�bad_keyksz)TestBase.testStressfully.<locals>.bad_keycsg|]}�|��qSrr)�.0r)rrr�
<listcomp>psz,TestBase.testStressfully.<locals>.<listcomp>TFz+exception during sort left some permutationcsg|]}�t�d�|��qS)r)r�	randrange)r/r)r$rrr0}scSsg|]}||jf�qSr)r#)r/�errrr0~scSsg|]\}}|�qSrr)r/r2rrrrr0�sZ	stability)�range�extend�object�listrrr�reverser�shufflerrr	�assertRaisesrr)
rZsizesZpower�nr-�s�yr.Z
it_complainedZ	augmentedr)rr$r�testStressfully+sd



zTestBase.testStressfullyN)r r!r"r=rrrrr*src@seZdZdd�Zdd�ZdS)�TestBugscs:G�fdd�d���fdd�td�D��|�t�j�dS)NcseZdZ�fdd�ZdS)z"TestBugs.test_bug453523.<locals>.Ccs0�rt��dkr���n
��d�t��dkS)Ng�?r+g�?)r�pop�append)rr)�Lrrr�s

z)TestBugs.test_bug453523.<locals>.C.__lt__N)r r!r"rr)rArr�C�srBcsg|]
}���qSrr)r/r)rBrrr0�sz+TestBugs.test_bug453523.<locals>.<listcomp>�2)r3r9�
ValueErrorr)rr)rBrAr�test_bug453523�szTestBugs.test_bug453523cslg}xbtd�D]V}�fdd�}ddg�|jt�jt|�d��fdd�}|jt�jt|�d�|g}qWdS)N�cs"��d����||k||kS)Nr+)r@r?)r-r<)rArr�mutating_cmp�s
z7TestBugs.test_undetected_mutation.<locals>.mutating_cmprr)rcs$��d��dd�=||k||kS)Nr+)r@)r-r<)rArrrG�s

)r3r9rDrr)rZmemorywasterrrGr)rAr�test_undetected_mutation�sz!TestBugs.test_undetected_mutationN)r r!r"rErHrrrrr>�sr>c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestDecorateSortUndecoratecCsHd��}|dd�}t�|�|jtjd�dd�}|jt|�d�dS)Nz,The quick Brown fox Jumped over The lazy Dog)rcSs"|��|��}}||k||kS)N)�lower)r-r<ZxlowerZylowerrrr�my_cmp�sz9TestDecorateSortUndecorate.test_decorated.<locals>.my_cmp)�splitrr8r�strrJr)r�data�copyrKrrr�test_decorated�s
z)TestDecorateSortUndecorate.test_decoratedcCs"d��}|jt|jdd�d�dS)Nz,The quick Brown fox Jumped over The lazy DogcSsdS)Nrr)r-r<rrrr)�r*z>TestDecorateSortUndecorate.test_baddecorator.<locals>.<lambda>)r)rLr9�	TypeErrorr)rrNrrr�test_baddecorator�sz,TestDecorateSortUndecorate.test_baddecoratorcCsFdd�td�D�}|dd�}|jdd�d�|��|�||�dS)NcSsg|]}t�d�|f�qS)r)rr1)r/rrrrr0�sz=TestDecorateSortUndecorate.test_stability.<locals>.<listcomp>��cSs|dS)Nrr)�trrrr)�r*z;TestDecorateSortUndecorate.test_stability.<locals>.<lambda>)r)r3r�assertEqual)rrNrOrrr�test_stability�s
z)TestDecorateSortUndecorate.test_stabilitycCs@ttdd��}|dd�}|jt|jdd�d�|�||�dS)N���rcSsd|S)Nrr)r-rrrr)�r*zDTestDecorateSortUndecorate.test_key_with_exception.<locals>.<lambda>)r)r6r3r9�ZeroDivisionErrorrrU)rrN�duprrr�test_key_with_exception�sz2TestDecorateSortUndecorate.test_key_with_exceptioncs.ttd����fdd�}|jt�j|d�dS)Nrcs�dd�=td��dd�<|S)NrF)r3)r-)rNrr�k�s
z<TestDecorateSortUndecorate.test_key_with_mutation.<locals>.k)r)r6r3r9rDr)rr[r)rNr�test_key_with_mutation�sz1TestDecorateSortUndecorate.test_key_with_mutationcs6ttd���G�fdd�dt�}|jt�j|d�dS)Nrcs(eZdZdd�Z�fdd�Zdd�ZdS)zITestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKillercSsdS)Nr)rr-rrrr�szRTestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKiller.__init__cs�dd�=td��dd�<dS)NrF)r3)r)rNrr�__del__�s
zQTestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKiller.__del__cSst|�t|�kS)N)�id)rrrrrr�szPTestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKiller.__lt__N)r r!r"rr]rr)rNrr�
SortKiller�sr_)r)r6r3r5r9rDr)rr_r)rNr�test_key_with_mutating_del�sz5TestDecorateSortUndecorate.test_key_with_mutating_delcs6ttd���G�fdd�dt�}|jt�j|d�dS)Nrcs eZdZdd�Z�fdd�ZdS)zWTestDecorateSortUndecorate.test_key_with_mutating_del_and_exception.<locals>.SortKillercSs|dkrt�dS)Nr)r)rr-rrrr�sz`TestDecorateSortUndecorate.test_key_with_mutating_del_and_exception.<locals>.SortKiller.__init__cs"�dd�=ttd���dd�<dS)NrF)r6r3)r)rNrrr]�s
z_TestDecorateSortUndecorate.test_key_with_mutating_del_and_exception.<locals>.SortKiller.__del__N)r r!r"rr]r)rNrrr_�sr_)r)r6r3r5r9rr)rr_r)rNr�(test_key_with_mutating_del_and_exception�szCTestDecorateSortUndecorate.test_key_with_mutating_del_and_exceptioncCs>ttd��}t�|�|jdd�|�|ttddd���dS)NrT)r7�c���)r6r3rr8rrU)rrNrrr�test_reverse�s
z'TestDecorateSortUndecorate.test_reversecCs�dd�td�D�}|dd�}|dd�}dd�}dd�}|jt|�dd	�|jt|�d
�|�||�|jdd�dd	�|�||�dS)
NcSsg|]}t�d�|f�qS)r)rr1)r/rrrrr0�szETestDecorateSortUndecorate.test_reverse_stability.<locals>.<listcomp>rScSs"|d|d}}||k||kS)Nrr)r-r<�x0�y0rrrrK�szATestDecorateSortUndecorate.test_reverse_stability.<locals>.my_cmpcSs"|d|d}}||k||kS)Nrr)r-r<rerfrrr�my_cmp_reversed�szJTestDecorateSortUndecorate.test_reverse_stability.<locals>.my_cmp_reversedT)rr7)rcSs|dS)Nrr)r-rrrr)r*zCTestDecorateSortUndecorate.test_reverse_stability.<locals>.<lambda>)r3rrrU)rrNZcopy1Zcopy2rKrgrrr�test_reverse_stability�sz1TestDecorateSortUndecorate.test_reverse_stabilityN)r r!r"rPrRrVrZr\r`rardrhrrrrrI�s
rIc	Cs�t�d�t�|�|dd�}dd�|D�}dd�|D�}xZ|||gD]L}t|�}dd�tdd�|D��D�}x"t||�D]\}}|�||�q|WqHWdS)NrcSsg|]
}|f�qSrr)r/r-rrrr0sz:check_against_PyObject_RichCompareBool.<locals>.<listcomp>cSsg|]}|ff�qSrr)r/r-rrrr0scSsg|]}|d�qS)rr)r/r<rrrr0scSsg|]}d|f�qS)rr)r/r-rrrr0s)rZseedr8�sorted�zipZassertIs)	rrAZL_1ZL_2ZL_3Z	optimizedZ	reference�opt�refrrr�&check_against_PyObject_RichCompareBools

rmc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestOptimizedComparescCs�ddgddgddgg}xJ|D]B}|�t|j�|�tdd�|D�j�|�tdd�|D�j�qWdd	gd
d	gd	dgd	d
gg}x|D]}t||�q�WdS)Nr�foog)rocSsg|]
}|f�qSrr)r/r-rrrr0*szBTestOptimizedCompares.test_safe_object_compare.<locals>.<listcomp>cSsg|]}|ff�qSrr)r/r-rrrr0+srg�������?l)r9rQrrm)rZheterogeneous_listsrAZfloat_int_listsrrr�test_safe_object_compare$s



z.TestOptimizedCompares.test_safe_object_comparec	sdG��fdd�dt��Gdd�dt��Gdd�dt����fdd�td	�D�}|d
�|�t��|��WdQRX��fdd�td	�D�}|d
�|�t��dd�|D���WdQRXGd
d�d�}|�|�g}|�t|j�|�tdd�|D�j�ttd��dgdd�td�D�dgdd�td�D�dd�td�D�g}x|D]}t||��qLWdS)NcseZdZ��fdd�ZdS)zITestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyComparatorcs��_t�||�S)N)�	__class__r,r)rr)�
WackyList2�elemrrr:szPTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyComparator.__lt__N)r r!r"rr)rrrsrr�WackyComparator9srtc@seZdZdS)zDTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyList1N)r r!r"rrrr�
WackyList1>sruc@seZdZdd�ZdS)zDTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyList2cSst�dS)N)rD)rrrrrrBszKTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyList2.__lt__N)r r!r"rrrrrrrAsrrcsg|]}��|�|g��qSrr)r/r)rtrurrr0EszDTestOptimizedCompares.test_unsafe_object_compare.<locals>.<listcomp>rrccsg|]}��|�|g��qSrr)r/r)rtrurrr0JscSsg|]
}|f�qSrr)r/r-rrrr0Msc@seZdZdd�ZdS)zMTestOptimizedCompares.test_unsafe_object_compare.<locals>.PointlessComparatorcSstS)N)�NotImplemented)rrrrrrRszTTestOptimizedCompares.test_unsafe_object_compare.<locals>.PointlessComparator.__lt__N)r r!r"rrrrr�PointlessComparatorQsrwcSsg|]
}|f�qSrr)r/r-rrrr0VsrlcSsg|]}t|��qSr)rM)r/r-rrrr0[su￿cSsg|]}t|��qSr)�bytes)r/r-rrrr0\scSsg|]}tdd��|��qS)cSs||kS)Nr)r-r<rrrr)]r*zMTestOptimizedCompares.test_unsafe_object_compare.<locals>.<listcomp>.<lambda>)r)r/r-rrrr0]s)r,r6r3r9rDrrQrm)rrArwZlistsr)rtrurrrsr�test_unsafe_object_compare4s*
z0TestOptimizedCompares.test_unsafe_object_comparecCst|dd�td�D��dS)NcSsg|]}t|��qSr)rM)r/r-rrrr0bszCTestOptimizedCompares.test_unsafe_latin_compare.<locals>.<listcomp>r)rmr3)rrrr�test_unsafe_latin_compareas
z/TestOptimizedCompares.test_unsafe_latin_comparecCst|dd�td�D��dS)NcSsg|]}|�qSrr)r/r-rrrr0fszBTestOptimizedCompares.test_unsafe_long_compare.<locals>.<listcomp>r)rmr3)rrrr�test_unsafe_long_comparees
z.TestOptimizedCompares.test_unsafe_long_comparecCst|dd�td�D��dS)NcSsg|]}t|��qSr)�float)r/r-rrrr0jszCTestOptimizedCompares.test_unsafe_float_compare.<locals>.<listcomp>r)rmr3)rrrr�test_unsafe_float_compareis
z/TestOptimizedCompares.test_unsafe_float_comparecCs0t|td�gd�t|dd�td�D��dS)N�nanrcSsg|]}td��qS)r~)r|)r/�_rrrr0vszCTestOptimizedCompares.test_unsafe_tuple_compare.<locals>.<listcomp>)rmr|r3)rrrr�test_unsafe_tuple_comparems
z/TestOptimizedCompares.test_unsafe_tuple_comparecCs<|�tdddgj�|�tddgj�|�tddgj�dS)N)g�?g�?)F�A�)r'r)rr')r9rQr)rrrr�test_not_all_tuplesysz)TestOptimizedCompares.test_not_all_tuplesN)
r r!r"rpryrzr{r}r�r�rrrrrn#s-rn�__main__)N)ZtestrrZunittest�	functoolsrrr
rZTestCaserr>rIrmrnr �mainrrrr�<module>s
 [%]\