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_peepholer.cpython-37.opt-1.pyc
B

��g<3�@sRddlZddlZddlmZGdd�de�ZGdd�dej�ZedkrNe��dS)�N)�BytecodeTestCasec@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%S)&�
TestTranformscCs0dd�}|�|d�|�|d�|�|d�dS)NcSs|dks
~dS)N��)�xrr�//usr/local/lib/python3.7/test/test_peepholer.py�unot
sz%TestTranforms.test_unot.<locals>.unotZ	UNARY_NOT�POP_JUMP_IF_FALSEZPOP_JUMP_IF_TRUE)�assertNotInBytecode�assertInBytecode)�selfrrrr�	test_unotszTestTranforms.test_unotcCs0x*dD]"\}}t|dd�}|�|d|�qWdS)N))z
not a is bzis not)z
not a in bznot in)znot a is not b�is)znot a not in b�in��singleZ
COMPARE_OP)�compiler)r�lineZcmp_op�coderrr�test_elim_inversion_of_is_or_insz-TestTranforms.test_elim_inversion_of_is_or_incCs|dd�}dd�}dd�}x<|df|df|dffD]"\}}|�|d	�|�|d
|�q0Wdd�}|�|d	�|�|d
d�dS)NcSsd}d}|S)Nr)rrrr�fsz0TestTranforms.test_global_as_constant.<locals>.fcSsd}|S)NTr)rrrr�g!sz0TestTranforms.test_global_as_constant.<locals>.gcSsd}|S)NFr)rrrr�h$sz0TestTranforms.test_global_as_constant.<locals>.hTFZLOAD_GLOBAL�
LOAD_CONSTcSsdS)z1Adding a docstring made this test fail in Py2.5.0Nrrrrrr,s)r
r)rrrr�func�elemrrr�test_global_as_constants z%TestTranforms.test_global_as_constantcCs@dd�}xdD]}|�||�qWxdD]}|�||�q(WdS)NcSs
xqWtS)N)�listrrrrr5sz'TestTranforms.test_while_one.<locals>.f)rr	)�
JUMP_ABSOLUTE)r
r)rrrrrr�test_while_one3s


zTestTranforms.test_while_onecCsFx@dD]8\}}t|dd�}|�||�|�|d�|�|d�qWdS)N))za, = a,r)za, b = a, bZROT_TWO)za, b, c = a, b, cZ	ROT_THREErr�BUILD_TUPLEZUNPACK_TUPLE)rrr
)rrrrrrr�test_pack_unpack>szTestTranforms.test_pack_unpackcCs�x6dD].\}}t|dd�}|�|d|�|�|d�qWttttd���dd�}|�|d�dd�t�|�D�}|�t	|�d	�d
d�}dS)N))z	a = 1,2,3)�r�)z
("a","b","c"))�a�b�c)z
a,b,c = 1,2,3)r"rr#)z(None, 1, None))Nr"N)z((1, 2), 3, 4)))r"rr#�rrrr i'cSsg|]}|jdkr|�qS)r)�opname)�.0�instrrrr�
<listcomp>YszETestTranforms.test_folding_of_tuples_of_constants.<locals>.<listcomp>rcdSs�ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
gdfdS)Nrr"rr#r'�����	rrrrr�crater`szATestTranforms.test_folding_of_tuples_of_constants.<locals>.crater)
rrr
�repr�tuple�range�dis�get_instructions�assertEqual�len)rrrrZload_constsr1rrr�#test_folding_of_tuples_of_constantsIsz1TestTranforms.test_folding_of_tuples_of_constantscCs<x6dD].\}}t|dd�}|�|d|�|�|d�qWdS)N))za in [1,2,3])r"rr#)za not in ["a","b","c"])r$r%r&)za in [None, 1, None])Nr"N)za not in [(1, 2), 3, 4]))r"rr#r'rrrZ
BUILD_LIST)rrr
)rrrrrrr�"test_folding_of_lists_of_constantsns
z0TestTranforms.test_folding_of_lists_of_constantsc	Cs�x�dtdddh�fdtdddh�fd	tddh�fd
tdddh�fd
tdddh�ffD].\}}t|dd�}|�|d�|�|d|�qTWdd�}dd�}|�|d��|�|d��|�|d��|�|d��dS)Nza in {1,2,3}r"rr#za not in {"a","b","c"}r$r&r%za in {None, 1, None}za not in {(1, 2), 3, 4})r"rr'za in {1, 2, 3, 3, 2, 1}rrZ	BUILD_SETrcSs|dkS)N>r"rr#r)r$rrrr�sz:TestTranforms.test_folding_of_sets_of_constants.<locals>.fcSs|dkS)N>r"rr#r)r$rrrr�sz:TestTranforms.test_folding_of_sets_of_constants.<locals>.g)�	frozensetrr
rZ
assertTrue)rrrrrrrrr�!test_folding_of_sets_of_constantszsz/TestTranforms.test_folding_of_sets_of_constantscCsxPdD]H\}}t|dd�}|�|d|�x$t�|�D]}|�|j�d��q4WqWtddd�}|�|dd�|�|dd�td	dd�}|�|dd
�|�dd
|j�tddd�}|�|dd
�|�dd
>|j�tddd�}|�|dd
�|�dd
|j�dS)N))z	a = 2+3+4r0)z"@"*4z@@@@)za="abc" + "def"Zabcdef)za = 3**4�Q)za = 3*4�)z	a = 13//4r#)za = 14%4r)za = 2+3r,)za = 13-4r0)za = (12,13)[1]�
)za = 13 << 2�4)za = 13 >> 2r#)z
a = 13 & 7r,)z
a = 13 ^ 7�
)z
a = 13 | 7�rrr�BINARY_za=2+"b"rr%za="x"*10000i'rz	a=1<<1000i�r"z	a=2**1000)	rrr5r6�assertFalser(�
startswithZassertNotIn�	co_consts)rrrrr*rrr�#test_folding_of_binops_on_constants�s$z1TestTranforms.test_folding_of_binops_on_constantscCs�tddd�}|�|dd�|�|d�tddd�}|�|dd�|�|d�td	dd�}|�|dd
�|�|d�tddd�}|�|d�dS)Nz"foo"[0]rrrrZ
BINARY_SUBSCRu	"a￿"[1]u￿u	"𒍅"[0]u𒍅z	"fuu"[10])rrr
)rrrrr�test_binary_subscr_on_unicode�sz+TestTranforms.test_binary_subscr_on_unicodecCs�xPdD]H\}}t|dd�}|�|d|�x$t�|�D]}|�|j�d��q4WqWdd�}x$t�|�D]}|�|j�d��qfWx8dD]0\}}}t|dd�}|�|d|�|�||�q�WdS)	N))z-0.5g�)z-0.0g�)z
-(1.0-1.0)g�)z-0r)z~-2r")z+1r"rrr�UNARY_cSsdS)Ng�rrrrr�negzero�szDTestTranforms.test_folding_of_unaryops_on_constants.<locals>.negzero))z-"abc"�abcZUNARY_NEGATIVE)z~"abc"rKZUNARY_INVERT)rrr5r6rDr(rE)rrrrr*rJr(rrr�%test_folding_of_unaryops_on_constants�sz3TestTranforms.test_folding_of_unaryops_on_constantscCs>dd�}|�|dd�dd�t�|�D�}|�t|�d�dS)NcSs|S)Nr)rrrrr�sz/TestTranforms.test_elim_extra_return.<locals>.frcSsg|]}|jdkr|�qS)�RETURN_VALUE)r()r)r*rrrr+�sz8TestTranforms.test_elim_extra_return.<locals>.<listcomp>r")r
r5r6r7r8)rr�returnsrrr�test_elim_extra_return�sz$TestTranforms.test_elim_extra_returncCsHdd�}|�|d�|�|d�dd�t�|�D�}|�t|�d�dS)NcSs|r|S|S)Nr)ZcondZ
true_valueZfalse_valuerrrr�sz1TestTranforms.test_elim_jump_to_return.<locals>.f�JUMP_FORWARDrcSsg|]}|jdkr|�qS)rM)r()r)r*rrrr+�sz:TestTranforms.test_elim_jump_to_return.<locals>.<listcomp>r)r
r5r6r7r8)rrrNrrr�test_elim_jump_to_return�s
z&TestTranforms.test_elim_jump_to_returncCsHdd�}|�|d�|�|d�dd�t�|�D�}|�t|�d�dS)NcSs(|rdS|rdSxdSx|r dSdSdS)Nr"rr#r'r,r-r)�cond1�cond2rrrrsz5TestTranforms.test_elim_jump_after_return1.<locals>.frPrcSsg|]}|jdkr|�qS)rM)r()r)r*rrrr+
sz>TestTranforms.test_elim_jump_after_return1.<locals>.<listcomp>r-)r
r5r6r7r8)rrrNrrr�test_elim_jump_after_return1s
	z*TestTranforms.test_elim_jump_after_return1cCs`dd�}|�|d�dd�t�|�D�}|�t|�d�dd�t�|�D�}|�t|�d�dS)	NcSsx|rdSqWdS)Nr'r)rRrSrrrrsz5TestTranforms.test_elim_jump_after_return2.<locals>.frPcSsg|]}|jdkr|�qS)r)r()r)r*rrrr+sz>TestTranforms.test_elim_jump_after_return2.<locals>.<listcomp>r"cSsg|]}|jdkr|�qS)rM)r()r)r*rrrr+sr)r
r5r6r7r8)rrrNrrr�test_elim_jump_after_return2sz*TestTranforms.test_elim_jump_after_return2cCsdd�}|�|d�dS)NcSsdd�dd�}|S)Nr)�returncSsdS)Nrrrrrr!szBTestTranforms.test_make_function_doesnt_bail.<locals>.f.<locals>.gr)rrrrr sz7TestTranforms.test_make_function_doesnt_bail.<locals>.fZ
BINARY_ADD)r
)rrrrr�test_make_function_doesnt_bailsz,TestTranforms.test_make_function_doesnt_bailc	Cs~ddddddddd	g	}xb|D]Z}t|d
d�}xHt�|�D]:}|�|j�d��|�|j�d
��|�|j�d��q8WqWdS)Nz3 * -5z-3 * 5z2 * (3 * 4)z(2 * 3) * 4z
(-1, 2, 3)z
(1, -2, 3)z
(1, 2, -3)z(1, 2, -3) * 6z:lambda x: x in {(3 * -5) + (-1 - 6), (1, -2, 3) * 2, None}rrrIrCZBUILD_)rr5r6rDr(rE)rZexprs�err*rrr�test_constant_folding&s
z#TestTranforms.test_constant_foldingcCsdd�}|�|�d�dS)NcSsdsdrdSdS)NTFr"rrrrrrr;sz=TestTranforms.test_condition_with_binop_with_bools.<locals>.fr")r7)rrrrr�$test_condition_with_binop_with_bools:sz2TestTranforms.test_condition_with_binop_with_boolsN)�__name__�
__module__�__qualname__r
rrrr!r9r:r<rGrHrLrOrQrTrUrWrYrZrrrrrs$	
%'	
rc@seZdZdd�ZdS)�TestBugletsc	Cs(dd�}|�t��|�WdQRXdS)NcSsddh\}}||fS)Nr"r)r�yrrrrHsz%TestBuglets.test_bug_11510.<locals>.f)ZassertRaises�
ValueError)rrrrr�test_bug_11510DszTestBuglets.test_bug_11510N)r[r\r]rarrrrr^Bsr^�__main__)	r5ZunittestZtest.bytecode_helperrrZTestCaser^r[�mainrrrr�<module>s>