HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/test/__pycache__/test_peepholer.cpython-36.pyc
3


 \�2�@sjddlZddlZddlZddlZddlZddlmZGdd�de�ZGdd�dej�Z	e
dkrfej�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#S)$�
TestTranformscCs0dd�}|j|d�|j|d�|j|d�dS)NcSs|dks
~dS)N��)�xrr�&/usr/lib64/python3.6/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|d	d
�}|j|d|�qWdS)N�
not a is b�is not�
not a in b�not in�not a is not b�is�not a not in b�in��singleZ
COMPARE_OP�rr�rr�rr�rr)rrrr)�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]"\}}|j|d	�|j|d
|�q0Wdd�}|j|d	�|j|d
d�dS)NcSsd}d}|S)Nr)rrrr�f sz0TestTranforms.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r r!r"�func�elemrrr�test_global_as_constants z%TestTranforms.test_global_as_constantcCs@dd�}xdD]}|j||�qWxdD]}|j||�q(WdS)NcSs
xqWtS)N)�listrrrrr 8sz'TestTranforms.test_while_one.<locals>.fr#r	�
JUMP_ABSOLUTE)r#r	)r()r
r)rr r%rrr�test_while_one6s


zTestTranforms.test_while_onecCsFx@dD]8\}}t|dd�}|j||�|j|d	�|j|d
�qWdS)N�a, = a,r#�a, b = a, b�ROT_TWO�a, b, c = a, b, c�	ROT_THREErr�BUILD_TUPLEZUNPACK_TUPLE�r*r#�r+r,�r-r.)r0r1r2)rrr
)rrr%rrrr�test_pack_unpackAszTestTranforms.test_pack_unpackcCs�x6d!D].\}}t|d
d�}|j|d|�|j|d�qWttttd���d
d�}|j|d�dd�tj|�D�}|jt	|�d�dd�}dS)"N�	a = 1,2,3�r��
("a","b","c")�a�b�c�
a,b,c = 1,2,3�(None, 1, None)�((1, 2), 3, 4)�rrr#r/i'cSsg|]}|jdkr|�qS)r#)�opname)�.0�instrrrr�
<listcomp>\szETestTranforms.test_folding_of_tuples_of_constants.<locals>.<listcomp>cdSs�ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
ddddddddd	d
gdfdS)Nrr5rr6r>�����	rrrrr�cratercszATestTranforms.test_folding_of_tuples_of_constants.<locals>.crater�r5rr6�r4rI�r8r9r:�r7rK�r5rr6�r;rM�Nr5N�r<rO�r5r�rQr6r>�r=rR)rJrLrNrPrS)
rrr
�repr�tuple�range�dis�get_instructions�assertEqual�len)rrr%rZload_constsrHrrr�#test_folding_of_tuples_of_constantsLsz1TestTranforms.test_folding_of_tuples_of_constantscCs<x6dD].\}}t|dd
�}|j|d|�|j|d�qWdS)N�a in [1,2,3]r5rr6�a not in ["a","b","c"]r8r9r:�a in [None, 1, None]�a not in [(1, 2), 3, 4]r>rrr#Z
BUILD_LIST�r5rr6�r\r`�r8r9r:�r]rb�Nr5N�r^rd�r5r�rfr6r>�r_rg)rarcrerh)rrr
)rrr%rrrr�"test_folding_of_lists_of_constantsqsz0TestTranforms.test_folding_of_lists_of_constantsc	Cs�x�dtdddh�fdtdddh�fd	tddh�fd
tdddh�fdtdddh�ffD].\}}t|d
d�}|j|d�|j|d|�qTWdd�}dd�}|j|d��|j|d��|j|d��|j|d��dS)Nza in {1,2,3}r5rr6za not in {"a","b","c"}r8r:r9za in {None, 1, None}za not in {(1, 2), 3, 4}r>za in {1, 2, 3, 3, 2, 1}rrZ	BUILD_SETr#cSs|dkS)Nr5rr6>r5rr6r)r8rrrr �sz:TestTranforms.test_folding_of_sets_of_constants.<locals>.fcSs|dkS)Nr5rr6>r5rr6r)r8rrrr!�sz:TestTranforms.test_folding_of_sets_of_constants.<locals>.g)r5r)�	frozensetrr
rZ
assertTrue)rrr%rr r!rrr�!test_folding_of_sets_of_constants}sz/TestTranforms.test_folding_of_sets_of_constantscCsxPd8D]H\}}t|dd�}|j|d|�x$tj|�D]}|j|jjd��q4WqWtd dd�}|j|dd�|j|dd!�td"dd�}|j|dd#�|jd$d#|j�td%dd�}|j|dd&�|jd'd&>|j�td(dd�}|j|dd&�|jdd&|j�dS)9N�	a = 2+3+4rG�"@"*4�@@@@�a="abc" + "def"�abcdef�a = 3**4�Q�a = 3*4��	a = 13//4r6�a = 14%4r�a = 2+3rC�a = 13-4�a = (12,13)[1]�
�a = 13 << 2�4�a = 13 >> 2�
a = 13 & 7�
a = 13 ^ 7�
�
a = 13 | 7�rrr#�BINARY_za=2+"b"r9za="x"*10000i'rz	a=1<<1000i�r5z	a=2**1000�rlrG�rmrn�rorp�rqrr�rsrt�rur6�rvr�rwrC�rxrG�ryrz�r{r|�r}r6�r~rC�rr��r�r�)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)	rrrWrX�assertFalser?�
startswithZassertNotIn�	co_consts)rrr%rrArrr�#test_folding_of_binops_on_constants�s@z1TestTranforms.test_folding_of_binops_on_constantscCs�tddd�}|j|dd�|j|d�tddd�}|j|dd�|j|d�td	dd�}|j|dd
�|j|d�tddd�}|j|d�dS)Nz"foo"[0]rrr#r Z
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�}|j|d
|�x$tj|�D]}|j|jjd��q4WqWdd�}x$tj|�D]}|j|jjd��qfWx8d"D]0\}}}t|dd�}|j|d
|�|j||�q�WdS)#N�-0.5g�?�-0.0g�
-(1.0-1.0)�-0r�~-2r5�+1rrr#�UNARY_cSsdS)Ng�?gg�rrrrr�negzero�szDTestTranforms.test_folding_of_unaryops_on_constants.<locals>.negzero�-"abc"�abc�UNARY_NEGATIVE�~"abc"�UNARY_INVERT�࿩r�r����r�r����r�r��r�r�r�r5�r�r5)r�r�r�r�r�r��r�r�r��r�r�r�)r�r�)rrrWrXr�r?r�)rrr%rrAr�r?rrr�%test_folding_of_unaryops_on_constants�s(z3TestTranforms.test_folding_of_unaryops_on_constantscCs>dd�}|j|dd�dd�tj|�D�}|jt|�d�dS)NcSs|S)Nr)rrrrr �sz/TestTranforms.test_elim_extra_return.<locals>.fr#cSsg|]}|jdkr|�qS)�RETURN_VALUE)r?)r@rArrrrB�sz8TestTranforms.test_elim_extra_return.<locals>.<listcomp>r5)r
rWrXrYrZ)rr �returnsrrr�test_elim_extra_return�sz$TestTranforms.test_elim_extra_returncCsHdd�}|j|d�|j|d�dd�tj|�D�}|jt|�d�dS)NcSs|r|S|S)Nr)ZcondZ
true_valueZfalse_valuerrrr �sz1TestTranforms.test_elim_jump_to_return.<locals>.f�JUMP_FORWARDr(cSsg|]}|jdkr|�qS)r�)r?)r@rArrrrB�sz:TestTranforms.test_elim_jump_to_return.<locals>.<listcomp>r)r
rWrXrYrZ)rr r�rrr�test_elim_jump_to_return�s
z&TestTranforms.test_elim_jump_to_returncCsHdd�}|j|d�|j|d�dd�tj|�D�}|jt|�d�dS)NcSs(|rdS|rdSxdSx|r dSdSdS)Nr5rr6r>rCrDr)�cond1�cond2rrrr sz5TestTranforms.test_elim_jump_after_return1.<locals>.fr�r(cSsg|]}|jdkr|�qS)r�)r?)r@rArrrrBsz>TestTranforms.test_elim_jump_after_return1.<locals>.<listcomp>rD)r
rWrXrYrZ)rr r�rrr�test_elim_jump_after_return1s
	z*TestTranforms.test_elim_jump_after_return1cCs`dd�}|j|d�dd�tj|�D�}|jt|�d�dd�tj|�D�}|jt|�d�dS)	NcSsx|rdSqWdS)Nr>r)r�r�rrrr sz5TestTranforms.test_elim_jump_after_return2.<locals>.fr�cSsg|]}|jdkr|�qS)r()r?)r@rArrrrBsz>TestTranforms.test_elim_jump_after_return2.<locals>.<listcomp>r5cSsg|]}|jdkr|�qS)r�)r?)r@rArrrrBsr)r
rWrXrYrZ)rr r�rrr�test_elim_jump_after_return2sz*TestTranforms.test_elim_jump_after_return2cCsdd�}|j|d�dS)NcSsdd�dd�}|S)Nr5)�returncSsdS)Nrrrrrr!$szBTestTranforms.test_make_function_doesnt_bail.<locals>.f.<locals>.grr)r!rrrr #sz7TestTranforms.test_make_function_doesnt_bail.<locals>.fZ
BINARY_ADD)r
)rr rrr�test_make_function_doesnt_bail"sz,TestTranforms.test_make_function_doesnt_bailc	Cs~ddddddddd	g	}xb|D]Z}t|d
d�}xHtj|�D]:}|j|jjd��|j|jjd
��|j|jjd��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}rrr�r�ZBUILD_)rrWrXr�r?r�)rZexprs�errArrr�test_constant_folding)s
z#TestTranforms.test_constant_foldingN)�__name__�
__module__�__qualname__r
rr&r)r3r[rirkr�r�r�r�r�r�r�r�r�rrrrr	s"	
%'	
rc@seZdZdd�ZdS)�TestBugletsc	Cs(dd�}|jt��|�WdQRXdS)NcSsddh\}}||fS)Nr5r)r�yrrrr Dsz%TestBuglets.test_bug_11510.<locals>.f)ZassertRaises�
ValueError)rr rrr�test_bug_11510@szTestBuglets.test_bug_11510N)r�r�r�r�rrrrr�>sr��__main__)rW�re�sys�textwrapZunittestZtest.bytecode_helperrrZTestCaser�r��mainrrrr�<module>s7