Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_grammar.cpython-39.opt-2.pyc

a

��gt��@s�UddlmZmZmZddlZddlZddlZddlZddlTddlm	Z	ddl
Z
ddlmZddl
mZddl
Z
gd�Zgd�ZGdd	�d	ej�Zeed
<Gdd�d�ZGd
d�dej�Zedkr�e��dS)�)�check_syntax_error�check_syntax_warning�use_old_parserN)�*)�ChainMap)�ann_module2)Z0_0_0Z4_2Z1_0000_0000Z0b1001_0100Z0xffff_ffffZ0o5_7_7z	1_00_00.5z1_00_00.5e5Z1_00_00e5_1Z1e1_0z.1_4z.1_4e1Z0b_0Z0x_fZ0o_5Z1_00_00jz
1_00_00.5jZ1_00_00e5_1jz.1_4jz(1_2.5+3_3j)z(.5_6j))(Z0_Z42_z1.4j_Z0x_�0b1_Z0xf_Z0o5_z
0 if 1_Else 1Z0_b0Z0_xfZ0_o5Z0_7Z09_99Z	4_______2z0.1__4z0.1__4jZ0b1001__0100Z0xffff__ffffZ0x___Z0o5__77Z1e1__0Z1e1__0jz1_.4z1_.4jz1._4z1._4jz._5z._5jz1.0e+_1z1.0e+_1jz1.4_jz1.4e5_jZ1_e1z1.4_e1z1.4_e1jZ1e_1z1.4e_1z1.4e_1jz
(1+1.5_j_)z	(1+1.5_j)c@sheZdZddlmZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZdS)�
TokenTestsr�rcCs(d}|�|dd�d}|�|dd�dS)N�zbackslash for line continuationrzbackslash ending comment��assertEqual��self�x�r�-/usr/local/lib/python3.9/test/test_grammar.py�test_backslashjszTokenTests.test_backslashc	Csf|�td�td��|�dd�|�dd�|�dd�|�dd�|�ttd�ddlm}|dkr�|�dd�|�ddk�|�ddk�|�ddk�d	D]2}zt|�}Wq�ty�|�	d
|�Yq�0q�n�|dk�rT|�dd�|�d
dk�|�d
dk�|�ddk�dD]6}zt|�}Wn"t�yL|�	d
|�Yn0�qn|�	d|�dS)Nr�i����	�0x)�maxsizei�l��)Z
2147483648Z
0o40000000000Z0x100000000Z"0b10000000000000000000000000000000z(OverflowError on huge integer literal %rl����l���������l����)Z9223372036854775808Z0o2000000000000000000000Z0x10000000000000000ZA0b100000000000000000000000000000000000000000000000000000000000000zWeird maxsize value %r)
r
�type�assertRaises�SyntaxError�eval�sysr�
assertTrue�
OverflowError�fail)rr�srrrr�test_plain_integersts8
zTokenTests.test_plain_integerscCs$d}d}d}d}d}d}d}d}dS)Nrrl���?l�
~��l!]cll�����rrrrr�test_long_integers�szTokenTests.test_long_integerscCs0d}d}d}d}d}d}d}d}d}d}d}dS)Ng��Q�	@g�s@gj�t��?g��
�Bg��t� =g�W�H�BgF�@rrrrr�test_floats�szTokenTests.test_floatscCs6|�dndd�|�drdndd�|�ttd�dS)N�rz0 if 1Else 0)r
rrr�rrrr� test_float_exponent_tokenization�sz+TokenTests.test_float_exponent_tokenizationc	CsPtD] }|�t|�t|�dd���qtD]}|�tt|�q*|�ttd�dS)N�_�Z_0)�VALID_UNDERSCORE_LITERALSr
r�replace�INVALID_UNDERSCORE_LITERALSrr�	NameError)rZlitrrr�test_underscore_literals�s
z#TokenTests.test_underscore_literalscCs�|j}|dd�|dd�|dd�|dd�|dd�|dd	�|d
d	�|dd	�|dd
�|dd
�|dd�|dd�|dd�|dd�|dd�|dd�|dd�dS)NZ0b12z#invalid digit '2' in binary literalZ0b1_2Z0b2rzinvalid binary literalZ0bZ0o18z"invalid digit '8' in octal literalZ0o1_8Z0o8Z0o1_zinvalid octal literalZ0oZ0x1_zinvalid hexadecimal literalrZ1_zinvalid decimal literalZ012z`leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integersz1.2_Z1e2_z1e+r
�r�checkrrr�test_bad_numerical_literals�s(












�

z&TokenTests.test_bad_numerical_literalscCs
d}d}|�t|�dko||k�d}d}|�t|�dkoL||koLt|�dk�d}d}|�t|�dkoz||kozt|�dk�d}d}|�t|�d	ko�||k�d
}d
}|�t|�d	ko�||k�d}d}|�||�d}|�||�d}|�||�d}|�||�dS)Nr)r�'r%�'�"�"zdoesn't "shrink" does it�zdoes "shrink" doesn't itz2
The "quick"
brown fox
jumps over
the 'lazy' dog.
)r�len�ordr
�rr�yrrr�test_string_literals�s$"..zTokenTests.test_string_literalscCs$d}|�|tu�|�ttd�dS)N.z.. .)r�Ellipsisrrrrrrr�
test_ellipsis�szTokenTests.test_ellipsisc	CsZd}|D]L}|�t��}t|dd�Wd�n1s80Y|�dt|j��qdS)N)zdef foo(z	
def foo(z	def foo(
z<test>�execzunexpected EOF)rr�compileZassertIn�str�	exception)rZsamplesr!�cmrrr�test_eof_errors
*zTokenTests.test_eof_errorN)�__name__�
__module__�__qualname__�test.supportrrr"r#r$r'r.r1r;r=rCrrrrr	fs
$
(r	Zvar_annot_globalc@s$eZdZdd�Zdd�Zdd�ZdS)�CNScCs
i|_dS�N��_dctr&rrr�__init__
szCNS.__init__cCs||j|��<dSrI)rK�lower�r�item�valuerrr�__setitem__szCNS.__setitem__cCs
|j|SrIrJ�rrOrrr�__getitem__szCNS.__getitem__N�rDrErFrLrQrSrrrrrHsrHc@s eZdZddlmZmZdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Z d9d:�Z!d;d<�Z"d=d>�Z#d?d@�Z$dAdB�Z%dCdD�Z&dEdF�Z'e(�)dGdH�dIdJ��Z*dKdL�Z+dMdN�Z,dOdP�Z-dQdR�Z.dSdT�Z/dUdV�Z0dWdX�Z1dYdZ�Z2d[d\�Z3d]d^�Z4d_d`�Z5dadb�Z6dcdd�Z7dedf�Z8dgdh�Z9didj�Z:dkdl�Z;dmdn�Z<dodp�Z=dqdr�Z>dsdt�Z?dudv�Z@dwdx�ZAdydz�ZBd{d|�ZCd}d~�ZDdd��ZEd�d��ZFd�S)��GrammarTestsr)rrcCstd�}dS)Nz	1, 0 or 1)rrrrr�test_eval_input"szGrammarTests.test_eval_inputcCs@d}dg}dd�}ttgdd||�d<|�|dg�dS)N��*cSsdS�Nr%rrrrr�one+sz/GrammarTests.test_var_annot_basics.<locals>.onerr%)�int�listr
)rZvar1Zmy_lstrZrrr�test_var_annot_basics&s
z"GrammarTests.test_var_annot_basicscCs^t|d�t|d�t|d�t|d�t|d�t|d�t|d�t|d�t|d	�dS)
Nz
def f: intzx: int: strzdef f():
    nonlocal x: int
z[x, 0]: int
z	f(): int
z	(x,): intz"def f():
    (x, y): int = (1, 2)
z!def f():
    x: int
    global x
z!def f():
    global x
    x: int
r
r&rrr�test_var_annot_syntax_errors2s







z)GrammarTests.test_var_annot_syntax_errorsc	
Cs�|�t��ddtt<Wd�n1s,0Y|�t��dtt<Wd�n1s^0Ydd�}|�|ji�dd�}|�dd�}|�t��|�Wd�n1s�0Yd	d
�}z
|�Wn6t�y}z|�	t
|�t�WYd}~n
d}~00Gdd�d�}|�|jttd
��|�t��Gdd�d�}Wd�n1�s`0Y|�t�� Gdd�d|�}Wd�n1�s�0YdS)Nr%rcSsd}dt_|S)NZHello�r%r��a�b)�strrr�fOsz6GrammarTests.test_var_annot_basic_semantics.<locals>.fcSsdSrIrrrrr�f_OKTsz9GrammarTests.test_var_annot_basic_semantics.<locals>.f_OKcSst|�dSrI��print�rrrr�fbadWsz9GrammarTests.test_var_annot_basic_semantics.<locals>.fbadcSstt�dSrI)rgZno_such_globalrrrr�f2bad\sz:GrammarTests.test_var_annot_basic_semantics.<locals>.f2badc@s.eZdZUeed<dZeed<dZdd�ZdS)z6GrammarTests.test_var_annot_basic_semantics.<locals>.C�_C__foo�attrr!rcSs
||_dSrIrhrrrrrLisz?GrammarTests.test_var_annot_basic_semantics.<locals>.C.__init__N)	rDrErFr[�__annotations__r!r@�zrLrrrr�Ces
ro)rkr!c@seZdZUde_edS)z9GrammarTests.test_var_annot_basic_semantics.<locals>.CBadrN)rDrErFZno_such_name_definedrlr[rrrr�CBadms
rpc@s eZdZUeed<ge_edS)z:GrammarTests.test_var_annot_basic_semantics.<locals>.Cbad2rN)rDrErFr[rmrr:r\rrrr�Cbad2ps
rq)
r�ZeroDivisionErrorZno_nameZdoes_not_existr-r
rm�UnboundLocalError�	ExceptionZassertIsrr[r@)	rrdrerirj�erorprqrrr�test_var_annot_basic_semanticsFs,*&$
&.z+GrammarTests.test_var_annot_basic_semanticscCs8Gdd�dt�}Gdd�d|d�}|�|jdd�dS)Nc@seZdZedd��ZdS)z>GrammarTests.test_var_annot_metaclass_semantics.<locals>.CMetac[s
dt�iS�Nrm)rH)�metacls�name�bases�kwdsrrr�__prepare__vszJGrammarTests.test_var_annot_metaclass_semantics.<locals>.CMeta.__prepare__N)rDrErF�classmethodr|rrrr�CMetausr~c@seZdZUded<dS)z;GrammarTests.test_var_annot_metaclass_semantics.<locals>.CC�ANNOTZXXN)rDrErFrmrrrr�CCys
r�)�	metaclass�xxr)rr
rm)rr~r�rrr�"test_var_annot_metaclass_semanticstsz/GrammarTests.test_var_annot_metaclass_semanticsc	Cs~|�t��ttj�Wd�n1s*0Y|�tjdttt	j
ttfd��|�tjjdtd��|�t
ji�dS)Nr)r%rr:rd�{)Z123�o)r�AttributeErrorrg�testrmr
�
ann_moduler[r@�typing�Tuple�Mrrr&rrr�test_var_annot_module_semantics}s(�
�z,GrammarTests.test_var_annot_module_semanticscCs�ddlm}m}m}|�t��|�Wd�n1s:0Y|�t��|�Wd�n1sj0Y|�t��|d�Wd�n1s�0YdS)Nr)�	f_bad_ann�	g_bad_ann�	D_bad_annrW)Ztest.ann_module3r�r�r�rr-)rr�r�r�rrr�test_var_annot_in_module�s$$z%GrammarTests.test_var_annot_in_modulecCs`i}i}td||�|�|ddtd��|�t��|dWd�n1sR0YdS)Nz.'docstring'
__annotations__[1] = 2
x: int = 5
rmr)r%r)r>r
r[r�KeyError)rZgnsZlnsrrr�test_var_annot_simple_exec�s�z'GrammarTests.test_var_annot_simple_execcs�dt�i}td|�|�|ddt�|�|ddt�|�t��|ddWd�n1sh0Yi�G�fdd�d�}tdi|��|��ddt�dS)	Nrmz'X: int; Z: str = "Z"; (w): complex = 1jrrn�wcs(eZdZdd�Z�fdd�Zdd�ZdS)z5GrammarTests.test_var_annot_custom_maps.<locals>.CNS2cSs
i|_dSrIrJr&rrrrL�sz>GrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__init__cs||j|<|�|<dSrIrJrN��	nonloc_nsrrrQ�s
zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__setitem__cSs
|j|SrIrJrRrrrrS�szAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__getitem__NrTrr�rr�CNS2�sr�z
x: int = 1)rHr>r
r[r@rr�)r�nsr�rr�r�test_var_annot_custom_maps�s

*	z'GrammarTests.test_var_annot_custom_mapscsHt��d�i�G��fdd�d�}tdi|��|��ddt�dS)Nrmcs,eZdZ�fdd�Z�fdd�Zdd�ZdS)z1GrammarTests.test_var_annot_refleak.<locals>.CNS2csd�i|_dSrwrJr&)�cnsrrrL�sz:GrammarTests.test_var_annot_refleak.<locals>.CNS2.__init__cs||j|<|�|<dSrIrJrNr�rrrQ�s
z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__setitem__cSs
|j|SrIrJrRrrrrS�sz=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__getitem__NrTr�r�r�rrr��sr�zX: strr)rHr>r
r@)rr�rr�r�test_var_annot_refleak�s
	z#GrammarTests.test_var_annot_refleakcCsri}td|�|�|dd�d}t||�|�t|d��dg�dddtjd	�}td
|�|�|dd�dS)Nzx: tuple = 1, 2rr_zdef f():
    x: int = yieldrdr%�r��rW)rarb�cr�zx: Tuple[int, ...] = a,*b,c�r%rr�r�rW)r>r
r\r�r�)rr�Zstmtrrr�test_var_annot_rhs�s


zGrammarTests.test_var_annot_rhsc
sX
dd�}|�|d�|dii��dd�}dd�}|�|jjd�|�|jjd	�d
d�}dd
�}dd�}dd�}dd�}|�|d�|d�|dd�|dd�|�|d�|d�|dd�|dddddddddd�
|d�|d�|dd�|ddd�|dddddddddd�
|dd�|ddd�|dddd�|dddddddddd�
d�dd�}	|	�|	d�|	d �|	g�p�dg�|	gd�p�d�i�o�d�Rid�p�i��|	fid!di��|	fid!di�p�i��d�d"d#�}
|
d�|
dd�|
d�id$di��d�d%d&�}|dd�|ddd�|d'�|dgd(�R�|ddgd)�R�|d�id*di��d�d+d,�}|�|d�|dd�|d-�|dgd.�R�|d�id$di��|fiddd/���d�d0d1�}
|
d�|
dd�|
ddd�d�d2d3�}|dd�|ddd�|dddd�d�d4d5�}|�|d�|dd�|d6�|d �|fid!di��d�d7d8�}|d�|dd�|ddd�d�d9d:�}|dd�|ddd�|dddd�|d6�|d�id*di��d�d;d<�}|�|d�|dd�|ddd�|dgd=�R�|fiddd/���d�d>d?�}|d�|dd�|ddd�|dddd�|d6�|ddgd@�R�|dgd.�Rid*di��d�dAdB�}|dd�|ddd�|dddd�|ddddd�|d6�|ddgd@�R�|dgd(�RidCdi��ztd�idEdi��Wnt�y.Yn0|�dF�dGdH�}|dIdJ�dIdK�dLdM�}|dddIdN�|dddIdOdP�|dddIdOdQ�dIdN�dRdS�}|dddIdIdOdT�|dddIdOdIdU�|�ttdV�|�ttdW�|�ttdX�dYdZ�}|�|dgddg�Rddd[��d\ddd[�f�|�|dgd(�d�R�d6if�|�ttd]�|�|fid^d_d`���dd^d_d`�f�|�|fdad_idbd^i��dd^d_d`�f�t	|dc�t	|dd�t
de�dfdZ�}|�|jdgt
i�tdh�didZ�}|�|jdDti�tdh�djdZ�}|�|jdDti�d�tdh�dldZ�}|�|jdDti�tdh�dmdZ�}|�|jdDti�t
dh�dndZ�}|�|jdDt
i�ddo�dpdZ�}|�|jdqdi�ddo�drdZ�}|�|jdqdi�ddds�dtdZ�}|�|jddds��dddu�dvdZ�}|�|jddds��d�dddddw�dxdZ�}|�|jdddddw��d�ddydz�ddddddd{d|d}�d~dZ�}|�|jddddddd{d|d}��d�ddydz�dddtdddd{d|d�	d�dZ�}|�|jdddtdddd{d|d�	�Gd�d��d��}Gd�d��d�|�}|�|jjd�di�|�|jjd�di�d�d����t
de�d�dZ��}|�|jdgt
i�d��	p,�d�dZ��}�}d�dZ��}�fd�d��d�dZ��}d��d�gdd�dZ��}�����d�dZ��}�gdjjd�dZ��}d��fd�dZ�}d��fd�dZ�	}dd���fd�dZ�
}tde��fd�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}d�dZ�}dS)�NcSsdSrIrrrrr�f1��z%GrammarTests.test_funcdef.<locals>.f1rcSsdSrIr�Zone_argumentrrr�f2�r�z%GrammarTests.test_funcdef.<locals>.f2cSsdSrIr��twoZ	argumentsrrr�f3�r�z%GrammarTests.test_funcdef.<locals>.f3r�r�cSsdSrIr)Zone_argrrr�a1�r�z%GrammarTests.test_funcdef.<locals>.a1cSsdSrIr)r��argsrrr�a2�r�z%GrammarTests.test_funcdef.<locals>.a2cWsdSrIr��restrrr�v0�r�z%GrammarTests.test_funcdef.<locals>.v0cWsdSrIr�rar�rrr�v1�r�z%GrammarTests.test_funcdef.<locals>.v1cWsdSrIr�rarbr�rrr�v2�r�z%GrammarTests.test_funcdef.<locals>.v2r%rr�r�rW���rrcSsdSrIr�rarrr�d01�r�z&GrammarTests.test_funcdef.<locals>.d01�r%racSsdSrIrr`rrr�d11r�z&GrammarTests.test_funcdef.<locals>.d11rbcSsdSrIr�rarbr�rrr�d21r�z&GrammarTests.test_funcdef.<locals>.d21�r%rr��rr��r�r�cSsdSrIrr`rrr�d02r�z&GrammarTests.test_funcdef.<locals>.d02r_�rr`cSsdSrIrr�rrr�d12r�z&GrammarTests.test_funcdef.<locals>.d12cSsdSrIr�rarbr��drrr�d22r�z&GrammarTests.test_funcdef.<locals>.d22cWsdSrIrr�rrr�d01vr�z'GrammarTests.test_funcdef.<locals>.d01v)r%rr�r�cWsdSrIrr�rrr�d11v&r�z'GrammarTests.test_funcdef.<locals>.d11vcWsdSrIr�rarbr�r�rrr�d21v*r�z'GrammarTests.test_funcdef.<locals>.d21vcWsdSrIrr�rrr�d02v0r�z'GrammarTests.test_funcdef.<locals>.d02vr�cWsdSrIrr�rrr�d12v7r�z'GrammarTests.test_funcdef.<locals>.d12v�r�r�rWcWsdSrIr)rarbr�r�r�rrr�d22v?r�z'GrammarTests.test_funcdef.<locals>.d22vr�rsfooz/Bytes should not work as keyword argument namescSs|SrIr��keyrrr�pos0key1Pr�z+GrammarTests.test_funcdef.<locals>.pos0key1�dr�)�k2cSs||||fSrIr)�p1�p2�k1r�rrr�pos2key2Rr�z+GrammarTests.test_funcdef.<locals>.pos2key2)r���)r�r�)r�r�c[s|||||fSrIr)r�r�r�r��kwargrrr�pos2key2dictVr�z/GrammarTests.test_funcdef.<locals>.pos2key2dict)r��tokwarg1�tokwarg2)r�r�r�zdef f(*): passzdef f(*,): passzdef f(*, **kwds): passc_s||fSrIr)r��kwargsrrrrd_sz$GrammarTests.test_funcdef.<locals>.f�rr:)r%r�r�zf(1, x=2, *(3,4), x=5)Z	scrambledZfried)�eggs�spamr�r�z
f(*g(1=2))zf(**g(1=2)))�returncSsdSrIrrhrrrrdor�r�rhcSsdSrIrrhrrrrdqr�cSsdSrIrrhrrrrdsr�r5cSsdSrIrrhrrrrdur�cWsdSrIrrhrrrrdwr�c[sdSrIrrhrrrrdyr��r:cSsdSrIrr�rrrrd{r�r:cSsdSrIrr�rrrrd}r�)rbr�cSsdSrIrr�rrrrdr�)r�rbcSsdSrIrr�rrrrd�r�)rbr�ru�gcWsdSrIr)rarbr�r�rurdr�rrrrd�r��
��i�j��)rbr�rur��hr��kr�c_sdSrIr�rarbr�r�rurdr�r�r�r�r�rrrrd�s)	rbr�rurdr�r�r�r�r�c_sdSrIrr�rrrrd�sc@seZdZdd�dd�ZdS)z'GrammarTests.test_funcdef.<locals>.Spamr%)�	_Spam__kwcSsdSrIr)rr�rrrrd�sz)GrammarTests.test_funcdef.<locals>.Spam.fN)rDrErFrdrrrr�Spam�sr�c@seZdZdS)z&GrammarTests.test_funcdef.<locals>.HamN�rDrErFrrrr�Ham�r�r�r�cSs|SrIrrhrrr�null�r�z'GrammarTests.test_funcdef.<locals>.nullcSsdSrIrrhrrrrd�sFcSsdSrIrrhrrrrd�scSsdSrIrrhrrrrd�scs�|�SrIr�rd)r�rr�<lambda>�r�z+GrammarTests.test_funcdef.<locals>.<lambda>cSsdSrIrrhrrrrd�s.cSsdSrIrrhrrrrd�scSsdSrIrrhrrrrd�scSsdSrIrrhrrrrd�scs�SrIrr��closurerrrd�r�cs�SrIrrhr�rrrd�r��r�cs�SrIrr�r�rrrd�r�cs�SrIrrr�rrrd�r�cSsdSrIrr�rrrrd�r�cWsdSrIr�r�rrrrd�r�c[sdSrIr�r{rrrrd�r�cWsdSrIr�rar�rrrrd�r�c[sdSrIr�rar{rrrrd�r�cWsdSrIr�rbr�rrrrd�r�cSsdSrIr�rbrrrrd�r�c_sdSrIr�r�r{rrrrd�r�cWsdSrIr�rarbr�rrrrd�r�cSsdSrIrr`rrrrd�r�c_sdSrIr�rar�r{rrrrd�r�c_sdSrIr�rbr�r{rrrrd�r�c[sdSrIr�rbr{rrrrd�r�c_sdSrIr�rarbr�r{rrrrd�r�c[sdSrIr�rarbr{rrrrd�r�)r%)r%)r%)r%)r%r)r%r)r%)r%r)r%r)r%)r%)r%)r%r)r%r)r%r)r%r)r)r5)r�rW)r�rW)r�rW)r%)r
�__code__�co_varnamesr@�	TypeErrorr rrrrr\rmr[�floatrd�__call__)rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rdr�r�r�r)r�r�r�test_funcdef�s�






*























 � ��

�������







zGrammarTests.test_funcdefcCsVdd�}|�|�d�dd�}dd�}|�|�gd��d'dd�fd	d�fd
d�}|�|�d�d(dd�}|�|dd�d
�|�|ddd�d�t|d�t|d�dd�dd�}|�|dd�d�|�|dddd�d�dd�}dd�}dd�}	dd�}
dd�}dd�}dd�}
dd�}d d�}d!d�}d"d�}d#d�}d$d�}d%d�}d&d�}dS))NcSsdS�Nrrrrrrr��r�z+GrammarTests.test_lambdef.<locals>.<lambda>rcSsttSrI)rar�rrrrr��r�cSsdd�dD�S)NcSsg|]}d|k�qSr�r��.0rrrr�
<listcomp>�r�z?GrammarTests.test_lambdef.<locals>.<lambda>.<locals>.<listcomp>)���r�rrrrrrr��r�)rr%rr%cSs|SrIr�rnrrrr��r�cSs|�SrIrr�rrrr��r�cSs|�SrIrrhrrrr��r�rcSs|||SrIr)rr:rnrrrr��r�rWr�r�zlambda x: x = 2zlambda (None,): None�r�cSs|||SrIr)rr:r�rrrr��r��r��
cSsdSrrr�rrrr��r�cWsdSrrr�rrrr��r�c[sdSrrr�rrrr��r�cWsdSrrr�rrrr��r�c[sdSrrr�rrrr��r�cWsdSrrr�rrrr��r�cSsdSrrr�rrrr��r�c_sdSrrr�rrrr��r�cWsdSrrr�rrrr��r�cSsdSrrr`rrrr��r�c_sdSrrr�rrrr��r�c_sdSrrr�rrrr��r�c[sdSrrr�rrrr��r�c_sdSrrrrrrr��r�c[sdSrrrrrrr��r�)r%)r�r
r)r�l1�l2�l3�l4�l5�l6�l10Zl11Zl12Zl13Zl14Zl15Zl16Zl17Zl18Zl19Zl20Zl21Zl22Zl23Zl24rrr�test_lambdef�s<


zGrammarTests.test_lambdefcCsd}~dd�}|�dS)Nr%cSs
d}~dSrYrrhrrr�foo�sz*GrammarTests.test_simple_stmt.<locals>.foor)rrrrrr�test_simple_stmt�szGrammarTests.test_simple_stmtc	CsRd}d}d}}}d\}}}d}\}}}\}}}}t|d�t|d�dS)Nr%r�)r%r)r�r�z	x + 1 = 1z
a + 1 = b + 2r
)	rrr:rn�abcrarbr��xyzrrr�test_expr_stmt�s

zGrammarTests.test_expr_stmtcCsd}gd�}|D]�}d�|�}|D]�}|�|�}|j|d��D|�t|��t|�Wd�n1sh0YWd�n1s�0Y|�dd�}|j|d��D|�td��t|�Wd�n1s�0YWd�q"1s�0Yq"qdS)N)rgr>)z{} fooz{} {{1:foo}}zif 1: {} foozif 1: {} {{1:foo}}zif 1:
    {} foozif 1:
    {} {{1:foo}}zcall to '{}')�sourcerz(foo.)zinvalid syntax)�format�subTestZassertRaisesRegexrr>r+)r�keywordsZcases�keywordZ
custom_msg�caserrrr�(test_former_statements_refer_to_builtinss

Dz5GrammarTests.test_former_statements_refer_to_builtinscCs�gd�}|\}}}|||f}~~~~~d\}}}~~~d\}}}}	}
}}~~~~	~
~d\}}}}	}
}}~~~~	~
~td�}
|
dd�=tddd	�dS)
Nr�rZabcdefg�abcdr%rz-del a, (b[0].c, (d.e, f.g[1:2])), [h.i.j], ()�
<testcase>r>)r\r?)rrrr:rnrrarbr�r�rurdr�r&rrr�
test_del_stmts 



zGrammarTests.test_del_stmtcCsdSrIrr&rrr�test_pass_stmt5szGrammarTests.test_pass_stmtcCsqqdSrIrr&rrr�test_break_stmt<szGrammarTests.test_break_stmtcCs�d}|rd}qqd}|s<d}zWqd}Wqd}Yq0q|dkrN|�|�d}|std}zWd}qRWd}qRd}0qR|dkr�|�|�dS)Nr%rr)�okz&continue failed to continue inside tryz'continue inside try called except blockzfinally block not called�r )rr��msgrrr�test_continue_stmt@s,
�zGrammarTests.test_continue_stmtcsd�fdd�	}|�dS)Nr%rcshd}|rJ|d7}z(|r*|dkr*|d8}WqJ|d8}WqWq�Yq0q|dksZ|dkrd��d�dS)Nrr%z1continue then break in try/except in loop broken!r,)Zextra_burning_oil�countZ	big_hippor&rr�
test_innerds
z9GrammarTests.test_break_continue_loop.<locals>.test_inner)r%rr)rr0rr&r�test_break_continue_loopZs
z%GrammarTests.test_break_continue_loopcCsFdd�}dd�}dd�}|�|�}|�}|�|dd�t|d	�dS)
NcSsdSrIrrrrr�g1vr�z$GrammarTests.test_return.<locals>.g1cSsdSrYrrrrr�g2wr�z$GrammarTests.test_return.<locals>.g2cSsddg}dg|�RS)Nrr�r%rr
rrr�g3xsz$GrammarTests.test_return.<locals>.g3r�z unparenthesized star expr returnzclass foo:return 1r)rr2r3r4rr:rrr�test_returntszGrammarTests.test_returncCs~d}|dkr*|d7}zWq*qYq*0q|�|d�d}|dkrf|d7}zWqfq:Wqfq:Yqf0q:|�|d�d}|dkr�|d7}zddWq�qvYq�0qv|�|d�dD](}|�|d�zWq�q�Yq�0q�|�|d�dD]6}|�|d�zW�q&q�W�q&q�Y�q&0q�|�|d�dD]6}|�|d�zddW�qnnY�qn0�q6|�|d�dS�Nrrr%�rr%r�rr/rrr�test_break_in_finally�sV�
�
z"GrammarTests.test_break_in_finallycCsXd}|dkr,|d7}zWqq,Yq0q,q|�|d�d}|dkrh|d7}zWq<qhWq<q<Yq<0q<|�|d�d}|dkr�|d7}zddWqxq�Yqx0q�qx|�|d�dD]}zWq�nYq�0q�q�|�|d�dD]"}zWq��q
Wq�q�Yq�0q�|�|d�dD],}zddW�qnY�q0�qH�q|�|d�dSr6rr8rrr�test_continue_in_finally�sX�
�

z%GrammarTests.test_continue_in_finallycCsFdd�}|�|�d�dd�}|�|�d�dd�}|�|�d	�dS)
NcSszWdSYdS0dSrYrrrrrr2�sz/GrammarTests.test_return_in_finally.<locals>.g1r%cSszWdSYdS0dS)Nr�rrrrrrr3�s
�z/GrammarTests.test_return_in_finally.<locals>.g2r�cSs"zddWdSYdS0dS)Nr%rr�rrrrrr4�s
z/GrammarTests.test_return_in_finally.<locals>.g3r�r)rr2r3r4rrr�test_return_in_finally�sz#GrammarTests.test_return_in_finallycCsTdd�}|�|d�d�|�|d�d�dd�}|�|d�d�|�|d�d�dS)	NcSsTdD]D}d}|dkr|d7}z||W|r.qSq|rDYq0qqd||fS)Nr7rrr��endr�rr/Zcount2rrrr2s��z;GrammarTests.test_break_in_finally_after_return.<locals>.g1Fr�T)r<r%r�c	SsPdD]@}dD]6}z||W|r$qSq|r@Yq0qqd||fS)Nr7)r�rr<rr=rrrr3s�
�z;GrammarTests.test_break_in_finally_after_return.<locals>.g2r�rr2r3rrr�"test_break_in_finally_after_returns	z/GrammarTests.test_break_in_finally_after_returncCsTdd�}|�|d�d�|�|d�d�dd�}|�|d�d	�|�|d�d
�dS)NcSs@d}|dkr8|d7}z|W|r"qSq|r4Yq0qd|fS)Nrr�r%r<r�rr/rrrr2s��z>GrammarTests.test_continue_in_finally_after_return.<locals>.g1Fr%T)r<r�cSs8dD]*}z|W|rqSq|r,Yq0qd|fS)Nr7r<rr@rrrr3,s��z>GrammarTests.test_continue_in_finally_after_return.<locals>.g2r)r<r%rr>rrr�%test_continue_in_finally_after_returns
z2GrammarTests.test_continue_in_finally_after_returncCsdd�}dd�}dd�}dd�}dd�}dd�}t|d�t|d	�d
d�}dd�}t|d�t|d
�dd�}dd�}dd�}dd�}dd�}|�t|��dg�t|d�t|d�t|d�t|d�t|d�t|d�t|d�t|d�t|d�dS)Ncss
dVdSrYrrrrrr�9r�z"GrammarTests.test_yield.<locals>.gcssdEdHdS�Nrrrrrrr�:r�css
dV}dSrYrrhrrrr�<r�cssdEdH}dSrBrrhrrrr�=r�css
dVdS�N)r%r%rrrrrr�?r�css
dV}dSrCrrhrrrr�@r�zdef g(): yield from (), 1zdef g(): x = yield from (), 1cssddVfdSrYrrrrrr�Er�cssddEdHfdS�Nr%rrrrrrr�Fr�zdef g(): 1, yield 1zdef g(): 1, yield from ()csstdV�dSrYr�rrrrr�Jr�csstdVd�dSrYr�rrrrr�Kr�csstdEdH�dSrBr�rrrrr�Lr�csstdEdHd�dS)Nrr%r�rrrrr�Mr�cssd}dddg|�RVdS)N�r�rWr�r%rr�rr�rrrr�Or�)r%rr�r�rWr�zdef g(): f(yield 1)zdef g(): f(yield 1, 1)zdef g(): f(yield from ())zdef g(): f(yield from (), 1)�yieldz
yield fromzclass foo:yield 1zclass foo:yield from ()zdef g(a:(yield)): pass)rr
r\�rr�rrr�
test_yield7s6











zGrammarTests.test_yieldcCs~dd�}dd�}|j}|dd�|dd�|dd�|dd	�|d
d�|dd�|d
d�|dd�|dd�|dd�dS)Ncssdd�dVfD�dS)NcSsg|]}|�qSrrr	rrrr`r��HGrammarTests.test_yield_in_comprehensions.<locals>.g.<locals>.<listcomp>r%rrrrrr�`r�z4GrammarTests.test_yield_in_comprehensions.<locals>.gcssdd�dEdHfD�dS)NcSsg|]}|�qSrrr	rrrrar�rIrrrrrrr�ar�z def g(): [(yield x) for x in ()]z!'yield' inside list comprehensionz)def g(): [x for x in () if not (yield x)]z-def g(): [y for x in () for y in [(yield x)]]z def g(): {(yield x) for x in ()}z 'yield' inside set comprehensionz#def g(): {(yield x): x for x in ()}z!'yield' inside dict comprehensionz#def g(): {x: (yield x) for x in ()}z def g(): ((yield x) for x in ())z#'yield' inside generator expressionz%def g(): [(yield from x) for x in ()]z class C: [(yield x) for x in ()]z[(yield x) for x in ()]r
)rr�r0rrr�test_yield_in_comprehensions^sB����������z)GrammarTests.test_yield_in_comprehensionscCs@ztd��WntyYn0zt�Wnty:Yn0dS)Nzjust testing)�RuntimeError�KeyboardInterruptr&rrr�
test_raiseys
zGrammarTests.test_raisecCsdddl}ddl}ddl}ddlm}ddlm}ddlm}m}ddlm}m}ddlm}m}dS)Nr)�time)�path�argv)rrNrOrP)rrrNrOrPrrr�test_import�szGrammarTests.test_importcCsdSrIrr&rrr�test_global�szGrammarTests.test_globalcsd�d���fdd�}dS)NrcsdSrIrrr�rrrd�sz%GrammarTests.test_nonlocal.<locals>.fr)rrdrr�r�
test_nonlocal�szGrammarTests.test_nonlocalc
CslzWn.ty2}z|�d�WYd}~n
d}~00zWn.tyf}z|�d�WYd}~n
d}~00dS)Nz6'assert True' should not have raised an AssertionErrorz;'assert True, msg' should not have raised an AssertionError)�AssertionErrorr �rrurrr�test_assert�s zGrammarTests.test_assertFz Won't work if __debug__ is Falsec
Cs�zWn6ty:}z|�|jdd�WYd}~nd}~00|�d�zWn6ty�}z|�t|j�d�WYd}~nd}~00|�d�|�dd�t���(t�dt	�t
dd	d
�Wd�n1s�0YdS)Nrr-z%AssertionError not raised by assert 0z+AssertionError not raised by 'assert False'zassert(x, "msg")zassertion is always true�errorzassert x, "msg"r'r>)rTr
r�r r7r�warnings�catch_warnings�simplefilter�
SyntaxWarningr?rUrrr�testAssert2�s (
(
�
zGrammarTests.testAssert2cCsdSrIrr&rrr�test_if�szGrammarTests.test_ifcCsd}d}|�|d�dS)Nrrrrrrr�
test_while�szGrammarTests.test_whilecCs�dD]}qdD]
\}}}qGdd�d�}d}|d�D]}||}q4|dkrT|�d�g}d	D]\}|�|�q\|�|gd��dS)
Nr�rc@s$eZdZdd�Zdd�Zdd�ZdS)z&GrammarTests.test_for.<locals>.SquarescSs||_g|_dSrI)�max�sofar)rr_rrrrL�sz/GrammarTests.test_for.<locals>.Squares.__init__cSs
t|j�SrI)r7r`r&rrr�__len__�r�z.GrammarTests.test_for.<locals>.Squares.__len__cSsRd|kr|jksnt�t|j�}||krH|j�||�|d}q&|j|S)Nrr%)r_�
IndexErrorr7r`�append)rr��nrrrrS�s

z2GrammarTests.test_for.<locals>.Squares.__getitem__N)rDrErFrLrarSrrrr�Squares�srerr�izfor over growing sequence)r�r�r�)r rcr
)rr�r�r�rerdr�resultrrr�test_for�s


zGrammarTests.test_forc
CszddWntyYn0zddWn>ty>Yn.ty`}zWYd}~nd}~0Yn0zddWntttfy�Yn0zddWn*tttfy�}zWYd}~n
d}~00zWn0|�t��(tddd�tddd�Wd�n1�s0YdS)Nr%rz/try:
    pass
except Exception as a.b:
    pass�?r>z0try:
    pass
except Exception as a[b]:
    pass)rr�EOFErrorrrrr?)rr-rrr�test_try�s""*zGrammarTests.test_trycCsdSrIrr&rrr�
test_suiteszGrammarTests.test_suitecCsdsdrdsdsdrdS)Nr%Frr&rrr�	test_test'szGrammarTests.test_testcCs�ddk}ddkrddkrddkr ddkr(ddkr0ddkr8||ur@||urHddvrPddvrXddkr�dkr�dkr�dkr�dkr�dkr�dvr�|vr�|ur�|ur�nndSrDrrrrr�test_comparison2szGrammarTests.test_comparisoncs�d�fdd�	}|d�|d�|d�|d�|dd	�t���Lt�d
t�tddd
�tddd
�tddd
�tddd
�Wd�n1s�0YdS)N�"is" with a literalcs��||�dSrI�r)r�r-r&rrr0Dsz6GrammarTests.test_comparison_is_literal.<locals>.checkzx is 1zx is "thing"z1 is xzx is y is 1z
x is not 1z"is not" with a literalrWz	x is Noner'r>z
x is Falsez	x is Truezx is ...)rn�rXrYrZr[r?r/rr&r�test_comparison_is_literalCs

z'GrammarTests.test_comparison_is_literalcsl��fdd�}d�|d�|d�|d�|d�|d�|d	�|d
�|d�|d�|d
�|d�|d�|d�|d�|d�|d�|d�|d�|d�d�|d�|d�|d�|d�|d�|d�|d�|d�|d �|d!�d"�|d#�|d$�|d%�|d&�|d'�|d(�|d)�|d*�d+�|d,�d-�|d.�|d/�d0�|d1�|d2�d3�|d4�|d5�d6�|d7�d8�|d9�d:�|d;�|d<�|d=�d>�|d?�|d@�|dA�|dB�|dC�t���dt�dDt�tdEdFdG�tdHdFdG�tdIdFdG�tdJdFdG�tdKdFdG�tdLdFdG�Wd�n1�s^0YdS)MNcs��|��dSrIro)r��r-rrrr0Usz2GrammarTests.test_warn_missed_comma.<locals>.checkz-is not callable; perhaps you missed a comma\?z[(1, 2) (3, 4)]z[(x, y) (3, 4)]z[[1, 2] (3, 4)]z[{1, 2} (3, 4)]z[{1: 2} (3, 4)]z[[i for i in range(5)] (3, 4)]z[{i for i in range(5)} (3, 4)]z[(i for i in range(5)) (3, 4)]z![{i: i for i in range(5)} (3, 4)]z[f"{x}" (3, 4)]z[f"x={x}" (3, 4)]z["abc" (3, 4)]z[b"abc" (3, 4)]z[123 (3, 4)]z
[12.3 (3, 4)]z[12.3j (3, 4)]z
[None (3, 4)]z
[True (3, 4)]z[... (3, 4)]z2is not subscriptable; perhaps you missed a comma\?z[{1, 2} [i, j]]z[{i for i in range(5)} [i, j]]z[(i for i in range(5)) [i, j]]z[(lambda x, y: x) [i, j]]z[123 [i, j]]z
[12.3 [i, j]]z[12.3j [i, j]]z
[None [i, j]]z
[True [i, j]]z[... [i, j]]zKindices must be integers or slices, not tuple; perhaps you missed a comma\?z[(1, 2) [i, j]]z[(x, y) [i, j]]z[[1, 2] [i, j]]z[[i for i in range(5)] [i, j]]z[f"{x}" [i, j]]z[f"x={x}" [i, j]]z["abc" [i, j]]z[b"abc" [i, j]]z.indices must be integers or slices, not tuple;z[[1, 2] [3, 4]]z-indices must be integers or slices, not list;z[[1, 2] [[3, 4]]]z [[1, 2] [[i for i in range(5)]]]z,indices must be integers or slices, not set;z[[1, 2] [{3, 4}]]z [[1, 2] [{i for i in range(5)}]]z-indices must be integers or slices, not dict;z[[1, 2] [{3: 4}]]z#[[1, 2] [{i: i for i in range(5)}]]z2indices must be integers or slices, not generator;z [[1, 2] [(i for i in range(5))]]z1indices must be integers or slices, not function;z[[1, 2] [(lambda x, y: x)]]z,indices must be integers or slices, not str;z[[1, 2] [f"{x}"]]z[[1, 2] [f"x={x}"]]z[[1, 2] ["abc"]]z'indices must be integers or slices, notz[[1, 2] [b"abc"]]z[[1, 2] [12.3]]z[[1, 2] [12.3j]]z[[1, 2] [None]]z[[1, 2] [...]]rWz[(lambda x, y: x) (3, 4)]r'r>z[[1, 2] [i]]z[[1, 2] [0]]z[[1, 2] [True]]z[[1, 2] [1:2]]z[{(1, 2): 3} [i, j]]rpr/rrrr�test_warn_missed_commaTs�
z#GrammarTests.test_warn_missed_commacCsd}d}d}dS)Nr%rrrrrr�test_binary_mask_ops�sz!GrammarTests.test_binary_mask_opscCsd}d}d}dS)Nrrr%rrrrr�test_shift_ops�szGrammarTests.test_shift_opscCsd}d}d}d}dS)Nr%rrrrrrr�test_additive_ops�szGrammarTests.test_additive_opscCsd}d}d}d}dS)Nr%��?rgrrrrr�test_multiplicative_ops�sz$GrammarTests.test_multiplicative_opscCsd}d}d}d}d}dS)Nr%r���rwrrrrr�test_unary_ops�s
zGrammarTests.test_unary_opsc	Cs�ddl}ddl}|jd}|��}|jd��}d}|d}|d}|dd�}|dd�}|dd�}|dd�}|dd�}|dd�}|dd�}i}d	|d	<d
|d<d|d
<d|d<t|�}|jdd�d�|�t|�d�dS)NrrNZ01234rrW���������r%rr�r�r_r�r�cSst|�j|fSrI)rrDrhrrrr��r�z-GrammarTests.test_selectors.<locals>.<lambda>r�z[1, (1,), (1, 2), (1, 2, 3)])rrNrO�modulesr\�sortr
r@)	rrrNr�rrar!r��Lrrr�test_selectors�s,
zGrammarTests.test_selectorscCs�d}dpdpd}dpdpdddf}g}dg}dp6dp6dg}dpDdpDdddg}g}i}ddi}ddi}dpjddppdi}ddd�}ddd�}dddddd	d
�}dh}ddh}hd�}hd�}|}d
}d}dS)Nr%rr�rZr�)rZr�r�rWr�)rZr��threeZfourZfiveZsix>rZr�r�>rr�r�rr�rrrrr�
test_atoms�s,

zGrammarTests.test_atomscsGdd�d�}Gdd�d�}Gdd�d|�}Gdd�d|�}Gd	d
�d
|||�}Gdd�d�}d
d���Gdd�d��}dp~�Gdd�d��}�}	Gdd�d��}
�fdd�Gdd�d��}d�dgdGdd�d��}�����Gdd�d��}
�gd jjGd!d"�d"��}dS)#Nc@seZdZdS)z%GrammarTests.test_classdef.<locals>.BNr�rrrr�Br�r�c@seZdZdS)z&GrammarTests.test_classdef.<locals>.B2Nr�rrrr�B2r�r�c@seZdZdS)z&GrammarTests.test_classdef.<locals>.C1Nr�rrrr�C1r�r�c@seZdZdS)z&GrammarTests.test_classdef.<locals>.C2Nr�rrrr�C2	r�r�c@seZdZdS)z%GrammarTests.test_classdef.<locals>.DNr�rrrr�D
r�r�c@s$eZdZdd�Zdd�Zdd�ZdS)z%GrammarTests.test_classdef.<locals>.CcSsdSrIrr&rrr�meth1r�z+GrammarTests.test_classdef.<locals>.C.meth1cSsdSrIr)r�argrrr�meth2
r�z+GrammarTests.test_classdef.<locals>.C.meth2cSsdSrIr)rr�r�rrr�meth3r�z+GrammarTests.test_classdef.<locals>.C.meth3N)rDrErFr�r�r�rrrrrosrocSs|SrIrrhrrr�class_decoratorr�z3GrammarTests.test_classdef.<locals>.class_decoratorc@seZdZdS)z%GrammarTests.test_classdef.<locals>.GNr�rrrr�Gsr�Fc@seZdZdS)z%GrammarTests.test_classdef.<locals>.HNr�rrrr�Hsr�c@seZdZdS)z%GrammarTests.test_classdef.<locals>.INr�rrrr�Isr�cs�|�SrIr)r��r�rrr�r�z,GrammarTests.test_classdef.<locals>.<lambda>c@seZdZdS)z%GrammarTests.test_classdef.<locals>.JNr�rrrr�Jsr�.r%c@seZdZdS)z%GrammarTests.test_classdef.<locals>.KNr�rrrr�Ksr�c@seZdZdS)z%GrammarTests.test_classdef.<locals>.LNr�rrrrr� sr�rc@seZdZdS)z%GrammarTests.test_classdef.<locals>.MNr�rrrrr�"sr�)r)rr�r�r�r�r�ror�r�r�r�r�r�r�r�rr�r�
test_classdefs*

zGrammarTests.test_classdefcCs*gd�}|�dd�|D�dddd��dS)Nr�cSsi|]}||d�qSr�r�r
r�rrr�
<dictcomp>*r�z/GrammarTests.test_dictcomps.<locals>.<dictcomp>rr�r�r)r�numsrrr�test_dictcomps%szGrammarTests.test_dictcompsc	sZgd�}gd��gd�}��dd�|D�gd����dd�|D�gd����d	d�|D�gd
�����fdd�|D�gd�����fd
d�|D�gd����dd�td�D�dgddggd�gd�gd�g�dd�}��||�gd���fdd�}|�t�d�t�d�gd�}gd��gd����fdd�|D�}��|gd ��dS)!Nr�)�Apple�Banana�Coconut)z  Applez Banana zCoco  nut  cSsg|]}|���qSr)�strip)r
r!rrrr2r�z/GrammarTests.test_listcomps.<locals>.<listcomp>)r�r�z	Coco  nutcSsg|]}d|�qSr�rr	rrrr3r�)r�r�rr��cSsg|]}|dkr|�qSr�rr	rrrr4r�r�csg|]}�D]}||f�qqSrr�r
r�r!��strsrrr5r�))r%r��r%r��r%r�)rr��rr��rr�)r�r��r�r��r�r�)r�r��r�r��r�r�)rWr��rWr��rWr�cs(g|] }dd��D�D]}||f�qqS)cSsg|]}d|vr|�qS)rdr)r
rdrrrr;r�z:GrammarTests.test_listcomps.<locals>.<listcomp>.<listcomp>rr�r�rrr;r�)
r�r�r�r�r�r�r�r�r�r�cSsg|]}dd�|��qS)cs�fdd�t�d�D�S)Ncsg|]}�|�qSrrr�r�rrr?r�zLGrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>.<locals>.<listcomp>r%��ranger�rr�rr�?r�z8GrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>r)r
r�rrrr?r�rWr%)r%rr�)r%r�r�)r%r���@�cSsdd�|D�S)NcSs,g|]$}|dkrd|ko"dkn�qS)rrr�rr	rrrrCr�zEGrammarTests.test_listcomps.<locals>.test_in_func.<locals>.<listcomp>r)�lrrr�test_in_funcBsz1GrammarTests.test_listcomps.<locals>.test_in_func)FFFcs,��dd�dD�ddgddgdd	gg�dS)
NcSs"g|]}dd�||dfD��qS)cSsg|]}|�qSrr�r
r:rrrrHr�zUGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>.<listcomp>r%rr	rrrrHr�zJGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>)r%r�rWr%rr�r�rWr�rrr&rr�test_nested_frontGs�z6GrammarTests.test_listcomps.<locals>.test_nested_frontz"[i, s for i in nums for s in strs]z[x if y]))r%�Boeing)r�Ford)r��
Macdonalds))r��Airliner)r�Engine)��Cheeseburger))r%r�)r%r)rr)r�r�csDg|]<\}}�D].\}}�D] \}}||kr||kr||f�qqqSrr)r
ZsnoZsnameZpnoZpnameZsp_snoZsp_pno)�parts�suppartrrr`s
�))r�r�)r�r�)r�r�)r�r�)r
r�r)rr�Zspcsr�r�Z	suppliersrr)r�rr�r�r�test_listcomps,s8���

�zGrammarTests.test_listcompscs�dd�td�D�}|�t|�dd�td�D��zt|�|�d�WntyXYn0d�z(�fdd��D�}t|�|�d	�Wnty�Yn0|�td
d�dD��dd�dD��|�td
d�dD��dd�dD��dd�td�D��dd�dd��D�D�}|�t|�tdd�td�D���|�tdd�td�D��tdd�td�D���|�tdd�td�D��tdd�td�D���|�tdd�dd�td�D�D��tdd�td�D���|�tdd�dd�dd�td�D�D�D��tdd�td�D���|�tdd�d d�d!d�td�D�D�D��td"d�td�D���|�td#d�d$d�d%d�td�D�D�D��td&d�td�D���|�td'd�d(d�d)d�td�D�D�D��d*�t|d+�t|d,�dS)-Ncss |]}dd�td�D�VqdS)cSsg|]}|�qSrrr	rrrrmr�z7GrammarTests.test_genexps.<locals>.<genexpr>.<listcomp>r�Nr�r	rrr�	<genexpr>mr�z,GrammarTests.test_genexps.<locals>.<genexpr>r%cSsg|]}|�qSrrr	rrrrnr�z-GrammarTests.test_genexps.<locals>.<listcomp>r�z&should produce StopIteration exceptionc3s|]
}�VqdSrIr)r
r�r�rrr�wr�zshould produce TypeErrorcss |]}dD]}||fVq
qdS)r&Nr�r
rr:rrrr�}r�r&cSsg|]}dD]}||f�qqS)r&rr�rrrr}r�css |]}dD]}||fVq
qdS)�xyNrr�rrrr�~r��abcSsg|]}dD]}||f�qqS)r�rr�rrrr~r�cSsg|]}|�qSrrr	rrrr�r�css|]
}|VqdSrIrr	rrrr��r�css|]
}|VqdSrIrr�rrrr��r�cSsg|]}|�qSrrr	rrrr�r�css|]}|dVqdS�rNrr	rrrr��r�cSsg|]}|d�qSr�rr	rrrr�r�css|]}|dr||VqdSr�rr	rrrr��r�cSsg|]}|dr||�qSr�rr	rrrr�r�css|]
}|VqdSrIrr	rrrr��r�css|]
}|VqdSrIrr�rrrr��r�cSsg|]}|�qSrrr	rrrr�r�css|]
}|VqdSrIrr	rrrr��r�css|]
}|VqdSrIrr�rrrr��r�css|]
}|VqdSrIr�r
rnrrrr��r�cSsg|]}|�qSrrr	rrrr�r�css|]
}|VqdSrIrr	rrrr��r�cSsg|]}|�qSrrr�rrrr�r�css|]
}|VqdSrIrr�rrrr��r�cSsg|]}|�qSrrr	rrrr�r�css|]
}|VqdS�TNrr	rrrr��r�css|]
}|VqdSrIrr�rrrr��r�css|]
}|VqdSr�rr�rrrr��r�cSsg|]}|�qSrrr	rrrr�r�css|]
}|VqdSr�rr	rrrr��r�css|]}dr|VqdS)FNrr�rrrr��r�css|]
}|VqdSr�rr�rrrr��r�rzfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r�r
�nextr �
StopIterationrr\�sumr)rr�rbrr�r�test_genexpsks8$$"00:DDD2
zGrammarTests.test_genexpscs�d�dd�t��D�}d�|�tt|��d�d�d���fdd�t��D�}d�d�|�dd	�td�D�t|��|�d
d	�td�D�gd��|�tdd�td�D��gd��|�d
d	�dD�gd��|�tdd�dD��gd��dS)Nr�css|]
}|VqdSrIrr�rrrr��r�z;GrammarTests.test_comprehension_specials.<locals>.<genexpr>rWFc3s(|] }�rt��D]}||fVqqdSrIr��r
r�r���trrrr��r�TcSs"g|]}td�D]}||f�qqS�rWr�r�rrrr�r�z<GrammarTests.test_comprehension_specials.<locals>.<listcomp>cSs g|]}|dr|dr|�qSr�rr	rrrr�r�)r%rWr�css"|]}|dr|dr|VqdS)rr�Nrr	rrrr��r�cSsg|]
\}|�qSrrr	rrrr�r�))r�r�)r�rEcss|]\}|VqdSrIrr	rrrr��r�))r�)r�)r)r�r�r)r�r
r7r\rGrr�r�test_comprehension_specials�s "z(GrammarTests.test_comprehension_specialsc	Cs�Gdd�dt�}|��Wd�n1s,0Y|��}Wd�n1sR0Y|��\}}Wd�n1s|0Y|��6|��Wd�n1s�0YWd�n1s�0Y|��6}|��}Wd�n1s�0YWd�n1�s0Y|��8}|��Wd�n1�sF0YWd�n1�sf0Yt��s�gd�}|D]@}|j|d��t|dd�Wd�n1�s�0Y�q�dS)Nc@seZdZdd�Zdd�ZdS)z1GrammarTests.test_with_statement.<locals>.managercSsdS�Nr_rr&rrr�	__enter__�sz;GrammarTests.test_with_statement.<locals>.manager.__enter__cWsdSrIr)rr�rrr�__exit__�sz:GrammarTests.test_with_statement.<locals>.manager.__exit__N)rDrErFr�r�rrrr�manager�sr�)z�if 1:
                    with (
                        manager()
                    ):
                        pass
                z�if 1:
                    with (
                        manager() as x
                    ):
                        pass
                z�if 1:
                    with (
                        manager() as (x, y),
                        manager() as z,
                    ):
                        pass
                z�if 1:
                    with (
                        manager(),
                        manager()
                    ):
                        pass
                z�if 1:
                    with (
                        manager() as x,
                        manager() as y
                    ):
                        pass
                z�if 1:
                    with (
                        manager() as x,
                        manager()
                    ):
                        pass
                z�if 1:
                    with (
                        manager() as x,
                        manager() as y,
                        manager() as z,
                    ):
                        pass
                z�if 1:
                    with (
                        manager() as x,
                        manager() as y,
                        manager(),
                    ):
                        pass
                )r$z<string>r>)�objectrr!r?)rr�rr:Z
test_casesr$rrr�test_with_statement�s$<>@:z GrammarTests.test_with_statementcCs�dd�}|�dd�dd�dd�fD�dg�|�d	d�d
d�dd�fD�dg�|�d
n|dd�d
�|�drx|dd�nd
d
�|�dr�d
o�dndd�|�dr�d
o�dndd�|�d
o�dndd�|�dr�dp�|dd�ndd�|�d�p�|dd�n|dd�d�|�d�pd
n|dd�d
�|�dndd�|�d�r>dndd�|�dndd�|�d
ndd
�|�dndd�|�dndd�|�d�r�ddkndd�dS)NcSst|�|SrIrf)r-�retrrr�
_checkeval�sz2GrammarTests.test_if_else_expr.<locals>._checkevalcSsg|]}|�r|��qSrrr	rrrr�r�z2GrammarTests.test_if_else_expr.<locals>.<listcomp>cSsdS)NTrrrrrr��r�z0GrammarTests.test_if_else_expr.<locals>.<lambda>cSsdS�NFrrrrrr��r�TcSsg|]}|d�r|d��qS)Frr	rrrr�r�cSs|rdSdS)NFTrrhrrrr��r�cSs|rdSdS)NTFrrhrrrr��r�r%rWzcheck 1rzcheck 2r�zcheck 3rr�zcheck 4zcheck 5zcheck 6Fr�r�r�g@r)rr�rrr�test_if_else_expr�s$$$"zGrammarTests.test_if_else_exprcCsr|�dd�|�dd�|�dd�d}d}|�d||uu�|�d|u|u�|�d|uof|un�dS)Nr�rr�F)r
rZassertFalser9rrr�test_paren_evaluationsz"GrammarTests.test_paren_evaluationcCs>Gdd�d�}|�}|�||d�|d}|�|jd�dS)Nc@seZdZdd�Zdd�ZdS)z'GrammarTests.test_matrix_mul.<locals>.McSsdS)Nr�r�rr�rrr�
__matmul__sz2GrammarTests.test_matrix_mul.<locals>.M.__matmul__cSs
||_|SrI)�otherr�rrr�__imatmul__ sz3GrammarTests.test_matrix_mul.<locals>.M.__imatmul__N)rDrErFr�r�rrrrr�sr�r�rX)r
r�)rr��mrrr�test_matrix_muls
zGrammarTests.test_matrix_mulcCsxdd�}|�|jd�|�t|jjtj@��dd�}|dd��}|�|j�|�|jd�|�t|jjtj@��dS)	Nc�sdd�}t�IdHdS)NcSsdSrIrrrrrr�*sz8GrammarTests.test_async_await.<locals>.test.<locals>.sum)Zsomeobj)r�rrrr�)sz+GrammarTests.test_async_await.<locals>.testr�cSst|dd�|S)N�_markedT)�setattr)�funcrrr�	decorator2sz0GrammarTests.test_async_await.<locals>.decoratorc�sdS)N�rrrrr�test26sz,GrammarTests.test_async_await.<locals>.test2r�)	r
rDr�boolr�co_flags�inspectZCO_COROUTINEr�)rr�r�r�rrr�test_async_await(s
zGrammarTests.test_async_awaitcsfGdd�dt��Gdd�d����fdd�}|����|��d�Wd�n1sX0YdS)Nc@seZdZdS)z)GrammarTests.test_async_for.<locals>.DoneNr�rrrr�Done>r�r�c@seZdZdd�Zdd�ZdS)z*GrammarTests.test_async_for.<locals>.AItercSs|SrIrr&rrr�	__aiter__Asz4GrammarTests.test_async_for.<locals>.AIter.__aiter__c�st�dSrI)�StopAsyncIterationr&rrr�	__anext__Csz4GrammarTests.test_async_for.<locals>.AIter.__anext__N)rDrErFr�r�rrrr�AIter@sr�c�sN��2z3dHW}q6��2z3dHW\}}q6��2z3dHW}q66��dSrIrr��r�r�rrrFsz(GrammarTests.test_async_for.<locals>.foo�rtr�send�rrrr�r�test_async_for=s
zGrammarTests.test_async_forcsfGdd�dt��Gdd�d����fdd�}|����|��d�Wd�n1sX0YdS)Nc@seZdZdS)z*GrammarTests.test_async_with.<locals>.DoneNr�rrrrr�Ur�r�c@seZdZdd�Zdd�ZdS)z-GrammarTests.test_async_with.<locals>.managerc�sdSr�rr&rrr�
__aenter__Xsz8GrammarTests.test_async_with.<locals>.manager.__aenter__c�sdSr�r)r�excrrr�	__aexit__Zsz7GrammarTests.test_async_with.<locals>.manager.__aexit__N)rDrErFr�r�rrrrr�Wsr�c
�s*��4IdH�Wd�IdHq:1IdHs00Y��4IdH�}Wd�IdHqt1IdHsj0Y��4IdH�\}}Wd�IdHq�1IdHs�0Y��4IdH�R��4IdH�Wd�IdHq�1IdHs�0YWd�IdH�q*1IdH�s 0Y��4IdH�V}��4IdH�}Wd�IdH�qx1IdH�sn0YWd�IdH�q�1IdH�s�0Y��4IdH�V}��4IdH�Wd�IdH�q�1IdH�s�0YWd�IdH�q"1IdH�s0Y��dSrIrr��r�r�rrr]s*** X \ \z)GrammarTests.test_async_with.<locals>.foor�r�rr�r�test_async_withTs
zGrammarTests.test_async_withN)GrDrErFrGrrrVr]r^rvr�r�r�r�r�r�r�rrrrr%r(r)r*r.r1r5r9r:r;r?rArHrJrMrQrRrSrV�unittestZ
skipUnlessr\r]r^rgrjrkrlrmrqrsrtrurvrxrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrUs�.			
w'45'



R#!?#T
rU�__main__)rGrrrr�r�rrXZtest.ann_moduler�r��collectionsrr�rr*r,ZTestCaser	r[rmrHrUrD�mainrrrr�<module>s>7#	g

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists