Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_grammar.cpython-38.pyc
U

>��g��(@s@UddlmZmZddlZddlZddlZddlZddlTddlmZddl	Z	ddl
mZddlm
Z
ddlZdddd	d
ddd
dddddddddddddgZdddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBg(ZGdCdD�dDej�ZeedE<GdFdG�dG�ZGdHdI�dIej�ZedJk�r<e��dS)K���check_syntax_error�check_syntax_warningN)�*)�ChainMap)�ann_module2Z0_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�0/opt/cppython/lib/python3.8/test/test_grammar.py�test_backslashjszTokenTests.test_backslashc	Csj|�td�td��|�dd�|�dd�|�dd�|�dd�|�ttd�ddlm}|dkr�|�dd�|�ddk�|�ddk�|�ddk�d	D]4}zt|�}Wq�tk
r�|�	d
|�Yq�Xq�n�|dk�rX|�dd�|�d
dk�|�d
dk�|�ddk�dD]8}zt|�}Wn$tk
�rP|�	d
|�YnX�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�s0&&zTokenTests.test_string_literalscCs$d}|�|tk�|�ttd�dS)N.z.. .)r�Ellipsisrrrrrrr�
test_ellipsis�szTokenTests.test_ellipsisc
CsFd}|D]8}|�t��}t|dd�W5QRX|�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)��GrammarTestsrrcCs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<W5QRX|�t��dtt<W5QRXdd�}|�|ji�dd�}|�dd�}|�t��|�W5QRXd	d
�}z
|�Wn2tk
r�}z|�	t
|�t�W5d}~XYnXGdd�d�}|�|jttd
��|�t��Gdd�d�}W5QRX|�t��Gdd�d|�}W5QRXdS)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�)�	metaclassZxxr)rr
rm)rr~r�rrr�"test_var_annot_metaclass_semanticstsz/GrammarTests.test_var_annot_metaclass_semanticsc	Csj|�t��ttj�W5QRX|�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_semanticsc	Csnddlm}m}m}|�t��|�W5QRX|�t��|�W5QRX|�t��|d�W5QRXdS)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_modulec	CsLi}i}td||�|�|ddtd��|�t��|dW5QRXdS)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_execc	s�dt�i}td|�|�|ddt�|�|ddt�|�t��|ddW5QRXi�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
sr	dd�}|�|d�|di�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�|	d�p�di�o�d�d�p�i�|	fd!di�|	fd!di�p�i�d�d"d#�}
|
d�|
dd�|
d�d$di�d�d%d&�}|dd�|ddd�|d'�|d�d(��|d�d)��|d�d*di�d�d+d,�}|�|d�|dd�|d-�|d�d.��|d�d$di�|fddd/��d�d0d1�}
|
d�|
dd�|
ddd�d�d2d3�}|dd�|ddd�|dddd�d�d4d5�}|�|d�|dd�|d6�|d �|fd!di�d�d7d8�}|d�|dd�|ddd�d�d9d:�}|dd�|ddd�|dddd�|d6�|d�d*di�d�d;d<�}|�|d�|dd�|ddd�|d�d=��|fddd/��d�d>d?�}|d�|dd�|ddd�|dddd�|d6�|d�d@��|d�d.�d*di�d�dAdB�}|dd�|ddd�|dddd�|ddddd�|d6�|d�d@��|d�d(�dCdi�ztd�dEdi�Wntk
�r�YnX|�dF�dGdH�}|dIdJ�dIdK�dLdM�}|dddIdN�|dddIdOdP�|dddIdOdQ�dIdN�dRdS�}|dddIdIdOdT�|dddIdOdIdU�|�ttdV�|�ttdW�|�ttdX�dYdZ�}|�|d�ddg�ddd[��d\ddd[�f�|�|d�d(d���d6if�|�ttd]�|�|fd^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��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�Zkwargrrr�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�sr�r�cSs|SrIrrhrrr�null�r�z'GrammarTests.test_funcdef.<locals>.nullcSsdSrIrrhrrrrd�scs�SrIrr�Zclosurerrrd�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%)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)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�rr�r�test_funcdef�s�







 























���

�������zGrammarTests.test_funcdefcCsXdd�}|�|�d�dd�}dd�}|�|�dddg�d&dd�fdd�fd	d�}|�|�d�d'dd�}|�|dd
�d�|�|dd
d
�d�t|d�t|d�dd�dd�}|�|dd
�d�|�|dd
dd�d�dd�}dd�}dd�}	dd�}
dd�}dd�}dd�}
dd�}dd�}d d�}d!d�}d"d�}d#d�}d$d�}d%d�}dS)(NcSsdS�Nrrrrrr�<lambda>�r�z+GrammarTests.test_lambdef.<locals>.<lambda>rcSsttSrI)rar�rrrrr�r�cSsdd�dD�S)NcSsg|]}d|k�qSr�r��.0rrrr�
<listcomp>�sz?GrammarTests.test_lambdef.<locals>.<lambda>.<locals>.<listcomp>)���r�rrrrrrr�r�r%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_sdSrrr�rrrr�r�c[sdSrrr�rrrr�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_stmtcCs�d}ddddddg}|D]�}d�|�}|D]�}|�|�}|j|d	��&|�t|��t|�W5QRXW5QRX|�d
d�}|j|d	��&|�td��t|�W5QRXW5QRXq*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)�formatZsubTestZassertRaisesRegexrr>r+)r�keywordsZcases�keywordZ
custom_msgZcaserrrr�(test_former_statements_refer_to_builtins�s&�

z5GrammarTests.test_former_statements_refer_to_builtinscCs,dddg}|\}}}|||f}~~~~~dS)Nr%rr�r)rrrr:rnrrrr�
test_del_stmt
s



zGrammarTests.test_del_stmtcCsdSrIrr&rrr�test_pass_stmtszGrammarTests.test_pass_stmtcCsqqdSrIrr&rrr�test_break_stmtszGrammarTests.test_break_stmtcCs�d}|rd}qqd}|s<d}zWqd}Wqd}YqXq|dkrN|�|�d}|snd}z
W�qRW5d}XqR|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�YqXq|dksZ|dkrd��d�dS)Nrr%z1continue then break in try/except in loop broken!r!)Zextra_burning_oil�countZ	big_hippor&rr�
test_innerEs
z9GrammarTests.test_break_continue_loop.<locals>.test_inner)r%rr)rr%rr&r�test_break_continue_loop;s
z%GrammarTests.test_break_continue_loopcCsFdd�}dd�}dd�}|�|�}|�}|�|dd�t|d	�dS)
NcSsdSrIrrrrr�g1Wr�z$GrammarTests.test_return.<locals>.g1cSsdSrYrrrrr�g2Xr�z$GrammarTests.test_return.<locals>.g2cSsddg}d|�S)Nrr�r%)r%rrrrr�g3Ysz$GrammarTests.test_return.<locals>.g3r�z unparenthesized star expr returnzclass foo:return 1r
)rr'r(r)rr:rrr�test_returnUszGrammarTests.test_returncCshd}|dkr(|d7}dzW5�q(Xq|�|d�d}|dkrd|d7}dzW�q8W5�qdXq8|�|d�d}|dkr�|d7}dzddW5�q�Xqt|�|d�dD]$}|�|d�dzW5�q�Xq�|�|d�dD].}|�|d�dzW�q�W5��qXq�|�|d�dD]0}|�|d�dzddW5��qXX�q&|�|d�dS�Nrrr%�rr%r�rr$rrr�test_break_in_finallycsNz"GrammarTests.test_break_in_finallycCsNd}|dkr*|d7}dzW5�qXq*q|�|d�d}|dkrf|d7}dzW�qfW5�q:Xq:|�|d�d}|dkr�|d7}dzddW5�qvXq�qv|�|d�dD]}dzW5�q�Xq�q�|�|d�dD]"}dzW��qW5�q�Xq�|�|d�dD](}dzddW5��qX�q>�q|�|d�dSr+rr-rrr�test_continue_in_finally�sP



z%GrammarTests.test_continue_in_finallycCsFdd�}|�|�d�dd�}|�|�d�dd�}|�|�d	�dS)
NcSsdzW5�dSXrYrrrrrr'�sz/GrammarTests.test_return_in_finally.<locals>.g1r%cSsdz
W�dS�dSX)Nr�rrrrrrr(�s
z/GrammarTests.test_return_in_finally.<locals>.g2r�cSsdzddW5�dSX)Nr�r%rrrrrrr)�sz/GrammarTests.test_return_in_finally.<locals>.g3r�r)rr'r(r)rrr�test_return_in_finally�sz#GrammarTests.test_return_in_finallycCsTdd�}|�|d�d�|�|d�d�dd�}|�|d�d�|�|d�d�dS)	Nc	SsPdD]@}d}|dkr|d7}dz||W�S|r>�qXqqd||fS)Nr,rrr��endr�rr$Zcount2rrrr'�sz;GrammarTests.test_break_in_finally_after_return.<locals>.g1Fr�T)r1r%r�c
SsJdD]:}dD]0}dz||W�
S|r8�qXqqd||fS)Nr,)r�rr1rr2rrrr(�sz;GrammarTests.test_break_in_finally_after_return.<locals>.g2r�rr'r(rrr�"test_break_in_finally_after_return�s	z/GrammarTests.test_break_in_finally_after_returncCsTdd�}|�|d�d�|�|d�d�dd�}|�|d�d	�|�|d�d
�dS)NcSs<d}|dkr4|d7}dz|W�S|r.�qXqd|fS)Nrr�r%r1r�rr$rrrr'sz>GrammarTests.test_continue_in_finally_after_return.<locals>.g1Fr%T)r1r�c	Ss4dD]&}dz|W�S|r&�qXqd|fS)Nr,r1rr5rrrr(
sz>GrammarTests.test_continue_in_finally_after_return.<locals>.g2r)r1r%rr3rrr�%test_continue_in_finally_after_return�s
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�r�z"GrammarTests.test_yield.<locals>.gcssdEdHdS�Nrrrrrrr�r�css
dV}dSrYrrhrrrr�r�cssdEdH}dSr7rrhrrrr�r�css
dVdS�N)r%r%rrrrrr� r�css
dV}dSr8rrhrrrr�!r�zdef g(): yield from (), 1zdef g(): x = yield from (), 1cssddVfdSrYrrrrrr�&r�cssddEdHfdS�Nr%rrrrrrr�'r�zdef g(): 1, yield 1zdef g(): 1, yield from ()csstdV�dSrY�rdrrrrr�+r�csstdVd�dSrYr:rrrrr�,r�csstdEdH�dSr7r:rrrrr�-r�csstdEdHd�dS)Nrr%r:rrrrr�.r�cssd}d|�VdS)N)r�rWr�r%rr�)r%rr�rr�rrrr�0s)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_yields6











zGrammarTests.test_yieldcCs~dd�}dd�}|j}|dd�|dd�|dd�|dd	�|d
d�|dd�|d
d�|dd�|dd�|dd�dS)Ncssdd�dVfD�dS)NcSsg|]}|�qSrrrrrrrAs�HGrammarTests.test_yield_in_comprehensions.<locals>.g.<locals>.<listcomp>r%rrrrrr�Ar�z4GrammarTests.test_yield_in_comprehensions.<locals>.gcssdd�dEdHfD�dS)NcSsg|]}|�qSrrrrrrrBsr>rrrrrrr�Br�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_comprehensionscCsDztd��Wntk
r YnXzt�Wntk
r>YnXdS)Nzjust testing)�RuntimeError�KeyboardInterruptr&rrr�
test_raiseZszGrammarTests.test_raisecCsdddl}ddl}ddl}ddlm}ddlm}ddlm}m}ddlm}m}ddlm}m}dS)Nr)�time)�path�argv)rrCrDrE)rrrCrDrErrr�test_importaszGrammarTests.test_importcCsdSrIrr&rrr�test_globalnszGrammarTests.test_globalcsd�d���fdd�}dS)NrcsdSrIrrr�rrrdxsz%GrammarTests.test_nonlocal.<locals>.fr)rrdrr�r�
test_nonlocaltszGrammarTests.test_nonlocalc
Cs�dst�dstd��dd�s t�ds0tdd���zds:t�Wn,tk
rh}z|�d�W5d}~XYnXzdsxtd��Wn,tk
r�}z|�d�W5d}~XYnXdS)	Nr%cSs|SrIrrhrrrr�r�z*GrammarTests.test_assert.<locals>.<lambda>cSs|dSrYrrhrrrr�r�Tz6'assert True' should not have raised an AssertionErrorzthis should always passz;'assert True, msg' should not have raised an AssertionError)�AssertionErrorr �rrurrr�test_assert|szGrammarTests.test_assertTz Won't work if __debug__ is Falsec
Cs�zdstd��Wn4tk
rD}z|�|jdd�W5d}~XYnX|�d�zdsZt�Wn4tk
r�}z|�t|j�d�W5d}~XYnX|�d�|�dd�t���t�dt	�t
d	d
d�W5QRXdS)Nrr"z%AssertionError not raised by assert 0Fz+AssertionError not raised by 'assert False'zassert(x, "msg")zassertion is always true�errorzassert x, "msg"�
<testcase>r>)rIr
r�r r7r�warnings�catch_warnings�simplefilter�
SyntaxWarningr?rJrrr�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\|�|d
ddg�dS)
Nr�rc@s$eZdZdd�Zdd�Zdd�ZdS)z&GrammarTests.test_for.<locals>.SquarescSs||_g|_dSrI)�max�sofar)rrUrrrrL�sz/GrammarTests.test_for.<locals>.Squares.__init__cSs
t|j�SrI)r7rVr&rrr�__len__�r�z.GrammarTests.test_for.<locals>.Squares.__len__cSsRd|kr|jksnt�t|j�}||krH|j�||�|d}q&|j|S)Nrr%)rU�
IndexErrorr7rV�append)rr��nrrrrS�s

z2GrammarTests.test_for.<locals>.Squares.__getitem__N)rDrErFrLrWrSrrrr�Squares�sr[rr�izfor over growing sequence)r�r�r�r%rr�)r rYr
)rr�r�r�r[rZr�resultrrr�test_for�s


zGrammarTests.test_forc
Cs�zddWntk
r YnXzddWn>tk
rBYn,tk
rb}zW5d}~XYnYnXzddWntttfk
r�YnXzddWn(tttfk
r�}zW5d}~XYnXzW5XdS�Nr%r)rr�EOFErrorr�)rr"rrr�test_try�s.zGrammarTests.test_trycCsdSrIrr&rrr�
test_suite�szGrammarTests.test_suitecCsdsdrdsdsdrdS)Nr%Frr&rrr�	test_tests
zGrammarTests.test_testcCs�ddk}ddkrddkrddkr ddkr(ddkr0ddkr8||kr@||k	rHddkrPddkrXddkr�dkr�dkr�dkr�dkr�dkr�dkr�|kr�|kr�|k	r�nndSr9rrrrr�test_comparisonshzGrammarTests.test_comparisonc	s�d�fdd�	}|d�|d�|d�|d�|dd	�t���Bt�d
t�tddd
�tddd
�tddd
�tddd
�W5QRXdS)N�"is" with a literalcs��||�dSrI�r)r�r"r&rrr0"sz6GrammarTests.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 literalrLz	x is NonerMr>z
x is Falsez	x is Truezx is ...)rd�rNrOrPrQr?r/rr&r�test_comparison_is_literal!s

z'GrammarTests.test_comparison_is_literalc	sV��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���Zt�dDt�tdEdFdG�tdHdFdG�tdIdFdG�tdJdFdG�tdKdFdG�tdLdFdG�W5QRXdS)MNcs��|��dSrIre)r��r"rrrr03sz2GrammarTests.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] [...]]rLz[(lambda x, y: x) (3, 4)]rMr>z[[1, 2] [i]]z[[1, 2] [0]]z[[1, 2] [True]]z[[1, 2] [1:2]]z[{(1, 2): 3} [i, j]]rfr/rrhr�test_warn_missed_comma2s�
z#GrammarTests.test_warn_missed_commacCsd}d}d}dSr^rrrrr�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%rrrrrrr�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���rmrrrrr�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)NrrCZ01234rrW���������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)])rrCrD�modulesr\�sortr
r@)	rrrCr�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}dddh}dddh}|}d}d
}dS)Nr%rr�rZr�)rZr�r�rWr�)rZr��threeZfourZfiveZsixrxrr�rrrrr�
test_atoms�s,



zGrammarTests.test_atomsc	Cs|Gdd�d�}Gdd�d�}Gdd�d|�}Gdd�d|�}Gd	d
�d
|||�}Gdd�d�}d
d�}|Gdd�d��}dS)Nc@seZdZdS)z%GrammarTests.test_classdef.<locals>.BNr�rrrr�B�srzc@seZdZdS)z&GrammarTests.test_classdef.<locals>.B2Nr�rrrr�B2�sr{c@seZdZdS)z&GrammarTests.test_classdef.<locals>.C1Nr�rrrr�C1�sr|c@seZdZdS)z&GrammarTests.test_classdef.<locals>.C2Nr�rrrr�C2�sr}c@seZdZdS)z%GrammarTests.test_classdef.<locals>.DNr�rrrr�D�sr~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�meth3�r�z+GrammarTests.test_classdef.<locals>.C.meth3N)rDrErFrr�r�rrrrro�srocSs|SrIrrhrrr�class_decorator�r�z3GrammarTests.test_classdef.<locals>.class_decoratorc@seZdZdS)z%GrammarTests.test_classdef.<locals>.GNr�rrrr�G�sr�r)	rrzr{r|r}r~ror�r�rrr�
test_classdef�szGrammarTests.test_classdefcCs,dddg}|�dd�|D�dddd��dS)Nr%rr�cSsi|]}||d�qSr�r�rr�rrr�
<dictcomp>�sz/GrammarTests.test_dictcomps.<locals>.<dictcomp>r�r�r)r�numsrrr�test_dictcomps�s
zGrammarTests.test_dictcompscs�dddddg}dddg�d	d
dg}��dd
�|D�dddg���dd
�|D�dddddg���dd
�|D�dddg����fdd
�|D�ddddddddddd d!d"d#d$g����fd%d
�|D�ddddddd d!d#d$g
���d&d
�td�D�dgddgdddgdddd'gddd(d)d*gg�d+d,�}��||�d-d-d-g��fd.d/�}|�t�d0�t�d1�d2d3d4g}d5d6d7g�d8d9d:d;g���fd<d
�|D�}��|d=d>d?d@g�dS)ANr%rr�r�rW�Apple�Banana�Coconutz  Applez Banana zCoco  nut  cSsg|]}|���qSr)�strip)rr!rrrrsz/GrammarTests.test_listcomps.<locals>.<listcomp>z	Coco  nutcSsg|]}d|�qSr�rrrrrrsr�rr��cSsg|]}|dkr|�qSr�rrrrrrscsg|]}�D]}||f�qqSrr�rr�r!��strsrrrs)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|kr|�qS)rZr)rrdrrrrsz:GrammarTests.test_listcomps.<locals>.<listcomp>.<listcomp>rr�r�rrrscSsg|]}dd�|��qS)cs�fdd�t�d�D�S)Ncsg|]}�|�qSrrr�r�rrrszLGrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>.<locals>.<listcomp>r%��ranger�rr�rrr�z8GrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>r)rr�rrrrs���@�cSsdd�|D�S)NcSs,g|]$}|dkrd|ko"dkn�qS)rrr�rrrrrrszEGrammarTests.test_listcomps.<locals>.test_in_func.<locals>.<listcomp>r)�lrrr�test_in_funcsz1GrammarTests.test_listcomps.<locals>.test_in_funcFcs,��dd�dD�ddgddgdd	gg�dS)
NcSs"g|]}dd�||dfD��qS)cSsg|]}|�qSrr�rr:rrrrszUGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>.<listcomp>r%rrrrrrszJGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>)r%r�rWr%rr�r�rWr�rrr&rr�test_nested_fronts�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)rZsnoZsnameZpnoZpnameZsp_snoZsp_pno)�parts�suppartrrr0s�)r�r�)r�r�)r�r�)r�r�)r
r�r)rr�Zspcsr�r�Z	suppliersrr)r�rr�r�r�test_listcomps�sx

 ����*�

�����zGrammarTests.test_listcompscs�dd�td�D�}|�t|�dd�td�D��zt|�|�d�Wntk
rZYnXd�z(�fdd��D�}t|�|�d	�Wntk
r�YnX|�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|]}|�qSrrrrrrr=sz7GrammarTests.test_genexps.<locals>.<genexpr>.<listcomp>r�Nr�rrrr�	<genexpr>=sz,GrammarTests.test_genexps.<locals>.<genexpr>r%cSsg|]}|�qSrrrrrrr>sz-GrammarTests.test_genexps.<locals>.<listcomp>r�z&should produce StopIteration exceptionc3s|]
}�VqdSrIr)rr�r�rrr�Gszshould produce TypeErrorcss |]}dD]}||fVq
qdS)�abcdNr�rrr:rrrr�Msr�cSsg|]}dD]}||f�qqS)r�rr�rrrrMscss |]}dD]}||fVq
qdS)�xyNrr�rrrr�Ns�abcSsg|]}dD]}||f�qqS)r�rr�rrrrNscSsg|]}|�qSrrrrrrrPscss|]
}|VqdSrIrrrrrr�Qscss|]
}|VqdSrIrr�rrrr�QscSsg|]}|�qSrrrrrrrRscss|]}|dVqdS�rNrrrrrr�TscSsg|]}|d�qSr�rrrrrrTscss|]}|dr||VqdSr�rrrrrr�UscSsg|]}|dr||�qSr�rrrrrrUscss|]
}|VqdSrIrrrrrr�Vscss|]
}|VqdSrIrr�rrrr�VscSsg|]}|�qSrrrrrrrVscss|]
}|VqdSrIrrrrrr�Wscss|]
}|VqdSrIrr�rrrr�Wscss|]
}|VqdSrIr�rrnrrrr�WscSsg|]}|�qSrrrrrrrWscss|]
}|VqdSrIrrrrrr�XscSsg|]}|�qSrrr�rrrrXscss|]
}|VqdSrIrr�rrrr�XscSsg|]}|�qSrrrrrrrXscss|]
}|VqdS�TNrrrrrr�Yscss|]
}|VqdSrIrr�rrrr�Yscss|]
}|VqdSr�rr�rrrr�YscSsg|]}|�qSrrrrrrrYscss|]
}|VqdSr�rrrrrr�Zscss|]}dr|VqdS)FNrr�rrrr�Zscss|]
}|VqdSr�rr�rrrr�Zsrzfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r�r
�nextr �
StopIterationr�r\�sumr)rr�rbrr�r�test_genexps;s8$$"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�dddg�|�td
d�td�D��dddg�|�dd	�dD�dddg�|�tdd�dD��dddg�dS)Nr�css|]
}|VqdSrIrr�rrrr�`sz;GrammarTests.test_comprehension_specials.<locals>.<genexpr>rWFc3s(|] }�rt��D]}||fVqqdSrIr��rr�r���trrrr�ds

TcSs"g|]}td�D]}||f�qqS�rWr�r�rrrrfs
z<GrammarTests.test_comprehension_specials.<locals>.<listcomp>cSs g|]}|dr|dr|�qSr�rrrrrrjsr%r�css"|]}|dr|dr|VqdS)rr�Nrrrrrr�kscSsg|]
\}|�qSrrrrrrrns))r�r�)r�r�r�css|]\}|VqdSrIrrrrrr�os))r�)r�)rr�r)r�r
r7r\r<rr�r�test_comprehension_specials^s $z(GrammarTests.test_comprehension_specialsc
Cs�Gdd�dt�}|��W5QRX|��}W5QRX|��
\}}W5QRX|��|��W5QRXW5QRX|��}|��}W5QRXW5QRX|��}|��W5QRXW5QRXdS)Nc@seZdZdd�Zdd�ZdS)z1GrammarTests.test_with_statement.<locals>.managercSsdS�Nr_rr&rrr�	__enter__ssz;GrammarTests.test_with_statement.<locals>.manager.__enter__cWsdSrIr)rr�rrr�__exit__usz:GrammarTests.test_with_statement.<locals>.manager.__exit__N)rDrErFr�r�rrrr�managerrsr�)�object)rr�rr:rrr�test_with_statementqs


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|�|S)z@helper to check that evaluation of expressions is done correctlyrf)r"�retrrr�
_checkeval�sz2GrammarTests.test_if_else_expr.<locals>._checkevalcSsg|]}|�r|��qSrrrrrrr�sz2GrammarTests.test_if_else_expr.<locals>.<listcomp>cSsdS)NTrrrrrr�r�z0GrammarTests.test_if_else_expr.<locals>.<lambda>cSsdS�NFrrrrrr�r�TcSsg|]}|d�r|d��qS)Frrrrrr�scSs|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||kk�|�d|k|k�|�d|kof|kn�dS)Nr�rr�F)r
rZassertFalser9rrr�test_paren_evaluation�s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_mul�s
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�	decorator�sz0GrammarTests.test_async_await.<locals>.decoratorc�sdS)N�rrrrr�test2�sz,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_awaitc	sRGdd�dt��Gdd�d����fdd�}|����|��d�W5QRXdS)Nc@seZdZdS)z)GrammarTests.test_async_for.<locals>.DoneNr�rrrr�Done�sr�c@seZdZdd�Zdd�ZdS)z*GrammarTests.test_async_for.<locals>.AItercSs|SrIrr&rrr�	__aiter__�sz4GrammarTests.test_async_for.<locals>.AIter.__aiter__c�st�dSrI)�StopAsyncIterationr&rrr�	__anext__�sz4GrammarTests.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�rrr�sz(GrammarTests.test_async_for.<locals>.foo�rtr�send�rrrr�r�test_async_for�s
zGrammarTests.test_async_forc	sRGdd�dt��Gdd�d����fdd�}|����|��d�W5QRXdS)Nc@seZdZdS)z*GrammarTests.test_async_with.<locals>.DoneNr�rrrrr��sr�c@seZdZdd�Zdd�ZdS)z-GrammarTests.test_async_with.<locals>.managerc�sdSr�rr&rrr�
__aenter__�sz8GrammarTests.test_async_with.<locals>.manager.__aenter__c�sdSr�r)r�excrrr�	__aexit__�sz7GrammarTests.test_async_with.<locals>.manager.__aexit__N)rDrErFr�r�rrrrr��sr�c�s,��4IdH�W5QIdHRX��4IdH�}W5QIdHRX��4IdH�
\}}W5QIdHRX��4IdH�&��4IdH�W5QIdHRXW5QIdHRX��4IdH�&}��4IdH�}W5QIdHRXW5QIdHRX��4IdH�&}��4IdH�W5QIdHRXW5QIdHRX��dSrIrr��r�r�rrr�s      z)GrammarTests.test_async_with.<locals>.foor�r�rr�r�test_async_with�s
zGrammarTests.test_async_withN)GrDrErFrGrrrVr]r^rvr�r�r�r�r�r�r�r�rrrrrrrr#r&r*r.r/r0r4r6r=r?rBrFrGrHrK�unittestZ
skipUnlessrRrSrTr]r`rarbrcrgrirjrkrlrnrprwryr�r�r�r�r�r�r�r�r�r�r�r�rrrrrUs�.			
i'	45'



R#?#
rU�__main__)rGrrr�r�rrNZtest.ann_moduler�r��collectionsrr�rr*r,ZTestCaser	r[rmrHrUrD�mainrrrr�<module>s���7#	v


F1le Man4ger