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

��g��(@s4UddlmZddlZddlZddlZddlTddlmZddlZddlm	Z	ddl
mZddl
Z
dddd	d
ddd
dddddddddddddgZdddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBg(Z
GdCdD�dDej�ZeedE<GdFdG�dG�ZGdHdI�dIej�ZedJk�r0e��dS)K�)�check_syntax_errorN)�*)�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_Z0b1_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@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
TokenTestscCs(d}|�|dd�d}|�|dd�dS)N�zbackslash for line continuationrzbackslash ending comment)�assertEqual)�self�x�r�-/usr/local/lib/python3.7/test/test_grammar.py�test_backslashgszTokenTests.test_backslashc	Csr|�td�td��|�dd�|�dd�|�dd�|�dd�|�ttd�ddlm}|dkr�|�dd�|�ddk�|�ddk�|�ddk�x�d	D]4}yt|�}Wq�tk
r�|�	d
|�Yq�Xq�Wn�|dk�r`|�dd�|�d
dk�|�d
dk�|�ddk�xPdD]8}yt|�}Wn$tk
�rV|�	d
|�YnX�q"Wn|�	d|�dS)Nr�i����	�0x)�maxsizei�l��)Z
2147483648Z
0o40000000000Z0x100000000Z"0b10000000000000000000000000000000z(OverflowError on huge integer literal %rl����l����l����l����)Z9223372036854775808Z0o2000000000000000000000Z0x10000000000000000ZA0b100000000000000000000000000000000000000000000000000000000000000zWeird maxsize value %r)
r�type�assertRaises�SyntaxError�eval�sysr�
assertTrue�
OverflowError�fail)r	r�sr
rrr�test_plain_integersqs8


zTokenTests.test_plain_integerscCs$d}d}d}d}d}d}d}d}dS)Nrl����l���?l�
~��l!]cll�����r)r	r
rrr�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�@r)r	r
rrr�test_floats�szTokenTests.test_floatscCs6|�dndd�|�drdndd�|�ttd�dS)N�rz0 if 1Else 0)rrrr)r	rrr� test_float_exponent_tokenization�sz+TokenTests.test_float_exponent_tokenizationc	CsXx(tD] }|�t|�t|�dd���qWxtD]}|�tt|�q0W|�ttd�dS)N�_�Z_0)�VALID_UNDERSCORE_LITERALSrr�replace�INVALID_UNDERSCORE_LITERALSrr�	NameError)r	Zlitrrr�test_underscore_literals�s

 
z#TokenTests.test_underscore_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)r	r
�yrrr�test_string_literals�s0&&zTokenTests.test_string_literalscCs$d}|�|tk�|�ttd�dS)N.z.. .)r�Ellipsisrrr)r	r
rrr�
test_ellipsis�szTokenTests.test_ellipsisc
CsJd}x@|D]8}|�t��}t|dd�WdQRX|�dt|j��q
WdS)N)zdef foo(z	
def foo(z	def foo(
z<test>�execzunexpected EOF)rr�compileZassertIn�strZ	exception)r	Zsamplesr�cmrrr�test_eof_error�s

zTokenTests.test_eof_errorN)�__name__�
__module__�__qualname__r
rrrrr&r/r1r6rrrrres
$
(rZvar_annot_globalc@s$eZdZdd�Zdd�Zdd�ZdS)�CNScCs
i|_dS)N)�_dct)r	rrr�__init__�szCNS.__init__cCs||j|��<dS)N)r;�lower)r	�item�valuerrr�__setitem__�szCNS.__setitem__cCs
|j|S)N)r;)r	r>rrr�__getitem__�szCNS.__getitem__N)r7r8r9r<r@rArrrrr:�sr:c@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%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z e!�"d=d>�d?d@��Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdN�Z*dOdP�Z+dQdR�Z,dSdT�Z-dUdV�Z.dWdX�Z/dYdZ�Z0d[d\�Z1d]d^�Z2d_d`�Z3dadb�Z4dcdd�Z5dedf�Z6dgdh�Z7didj�Z8dkdl�Z9dmdn�Z:dodp�Z;dqdr�Z<dsdt�Z=duS)v�GrammarTestscCstd�}dS)Nz	1, 0 or 1)r)r	r
rrr�test_eval_inputszGrammarTests.test_eval_inputcCs@d}dg}dd�}ttgdd||�d<|�|dg�dS)N��*cSsdS)Nrrrrrr�onesz/GrammarTests.test_var_annot_basics.<locals>.onerr)�int�listr)r	Zvar1Zmy_lstrFrrr�test_var_annot_basicss
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_errorss







z)GrammarTests.test_var_annot_syntax_errorsc	
Cs>|�t��ddtt<WdQRX|�t��dtt<WdQRXdd�}|�|ji�dd�}|�dd�}|�t��|�WdQRXd	d
�}y
|�Wn2tk
r�}z|�	t
|�t�Wdd}~XYnXGdd�d�}|�|jttd
��|�t��Gdd�d�}WdQRX|�t��Gdd�d|�}WdQRXdS)NrrcSsd}dt_|S)NZHello)rr)�a�b)�strrr�f4sz6GrammarTests.test_var_annot_basic_semantics.<locals>.fcSsdS)Nrrrrr�f_OK9sz9GrammarTests.test_var_annot_basic_semantics.<locals>.f_OKcSst|�dS)N)�print)r
rrr�fbad<sz9GrammarTests.test_var_annot_basic_semantics.<locals>.fbadcSstt�dS)N)rPZno_such_globalrrrr�f2badAsz:GrammarTests.test_var_annot_basic_semantics.<locals>.f2badc@s.eZdZUeed<dZeed<dZdd�ZdS)z6GrammarTests.test_var_annot_basic_semantics.<locals>.C�_C__foo�attrrrcSs
||_dS)N)r
)r	r
rrrr<Nsz?GrammarTests.test_var_annot_basic_semantics.<locals>.C.__init__N)	r7r8r9rG�__annotations__rr4�zr<rrrr�CJs
rW)rSrc@seZdZUde_edS)z9GrammarTests.test_var_annot_basic_semantics.<locals>.CBadrN)r7r8r9Zno_such_name_definedrTrGrrrr�CBadRs
rXc@s eZdZUeed<ge_edS)z:GrammarTests.test_var_annot_basic_semantics.<locals>.Cbad2r
N)r7r8r9rGrUr
r.rHrrrr�Cbad2Us
rY)
r�ZeroDivisionErrorZno_nameZdoes_not_existr%rrU�UnboundLocalError�	ExceptionZassertIsrrGr4)	r	rNrOrQrR�erWrXrYrrr�test_var_annot_basic_semantics+s,
"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)NrU)r:)�metacls�name�bases�kwdsrrr�__prepare__[szJGrammarTests.test_var_annot_metaclass_semantics.<locals>.CMeta.__prepare__N)r7r8r9�classmethodrcrrrr�CMetaZsrec@seZdZUded<dS)z;GrammarTests.test_var_annot_metaclass_semantics.<locals>.CC�ANNOTZXXN)r7r8r9rUrrrr�CC^s
rg)�	metaclassZxxrf)rrrU)r	rergrrr�"test_var_annot_metaclass_semanticsYsz/GrammarTests.test_var_annot_metaclass_semanticsc	Csj|�t��ttj�WdQRX|�tjdttt	j
ttfd��|�tjjdtd��|�t
ji�dS)Nr)rr
r.rN�{)Z123�o)r�AttributeErrorrP�testrUr�
ann_modulerGr4�typingZTuple�Mrr)r	rrr�test_var_annot_module_semanticsbs
z,GrammarTests.test_var_annot_module_semanticsc	Csnddlm}m}m}|�t��|�WdQRX|�t��|�WdQRX|�t��|d�WdQRXdS)Nr)�	f_bad_ann�	g_bad_ann�	D_bad_annrD)Ztest.ann_module3rrrsrtrr%)r	rrrsrtrrr�test_var_annot_in_moduleksz%GrammarTests.test_var_annot_in_modulec	CsLi}i}td||�|�|ddtd��|�t��|dWdQRXdS)Nz.'docstring'
__annotations__[1] = 2
x: int = 5
rUr)rr
)r2rrGr�KeyError)r	ZgnsZlnsrrr�test_var_annot_simple_execvsz'GrammarTests.test_var_annot_simple_execc	s�dt�i}td|�|�|ddt�|�|ddt�|�t��|ddWdQRXi�G�fdd�d�}tdi|��|��ddt�dS)	NrUz'X: int; Z: str = "Z"; (w): complex = 1jr
rV�wcs(eZdZdd�Z�fdd�Zdd�ZdS)z5GrammarTests.test_var_annot_custom_maps.<locals>.CNS2cSs
i|_dS)N)r;)r	rrrr<�sz>GrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__init__cs||j|<|�|<dS)N)r;)r	r>r?)�	nonloc_nsrrr@�s
zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__setitem__cSs
|j|S)N)r;)r	r>rrrrA�szAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__getitem__N)r7r8r9r<r@rAr)ryrr�CNS2�srzz
x: int = 1)r:r2rrGr4rrv)r	�nsrzr)ryr�test_var_annot_custom_mapss

	z'GrammarTests.test_var_annot_custom_mapscsHt��d�i�G��fdd�d�}tdi|��|��ddt�dS)NrUcs,eZdZ�fdd�Z�fdd�Zdd�ZdS)z1GrammarTests.test_var_annot_refleak.<locals>.CNS2csd�i|_dS)NrU)r;)r	)�cnsrrr<�sz:GrammarTests.test_var_annot_refleak.<locals>.CNS2.__init__cs||j|<|�|<dS)N)r;)r	r>r?)ryrrr@�s
z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__setitem__cSs
|j|S)N)r;)r	r>rrrrA�sz=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__getitem__N)r7r8r9r<r@rAr)r}ryrrrz�srzzX: strr
)r:r2rr4)r	rzr)r}ryr�test_var_annot_refleak�s
	z#GrammarTests.test_var_annot_refleakcs�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�ytd�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�tdh�djdZ�}|�|jdDti�t
dh�dkdZ�}|�|jdDt
i�ddl�dmdZ�}|�|jdndi�dddo�dpdZ�}|�|jdddo��d�dddddq�drdZ�}|�|jdddddq��d�ddsdt�dddddddudvdw�dxdZ�}|�|jdddddddudvdw��Gdydz�dz�}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)�NcSsdS)Nrrrrr�f1��z%GrammarTests.test_funcdef.<locals>.f1rcSsdS)Nr)�one_argumentrrr�f2�r�z%GrammarTests.test_funcdef.<locals>.f2cSsdS)Nr)�two�	argumentsrrr�f3�r�z%GrammarTests.test_funcdef.<locals>.f3)r�)r�r�cSsdS)Nr)Zone_argrrr�a1�r�z%GrammarTests.test_funcdef.<locals>.a1cSsdS)Nr)r��argsrrr�a2�r�z%GrammarTests.test_funcdef.<locals>.a2cWsdS)Nr)�restrrr�v0�r�z%GrammarTests.test_funcdef.<locals>.v0cWsdS)Nr)rKr�rrr�v1�r�z%GrammarTests.test_funcdef.<locals>.v1cWsdS)Nr)rKrLr�rrr�v2�r�z%GrammarTests.test_funcdef.<locals>.v2rr��rD���rrcSsdS)Nr)rKrrr�d01�r�z&GrammarTests.test_funcdef.<locals>.d01)rrKcSsdS)Nr)rKrLrrr�d11�r�z&GrammarTests.test_funcdef.<locals>.d11rLcSsdS)Nr)rKrL�crrr�d21�r�z&GrammarTests.test_funcdef.<locals>.d21)rrr�)rr�)r�r�cSsdS)Nr)rKrLrrr�d02�r�z&GrammarTests.test_funcdef.<locals>.d02)rr)r)rKrLcSsdS)Nr)rKrLr�rrr�d12�r�z&GrammarTests.test_funcdef.<locals>.d12cSsdS)Nr)rKrLr��drrr�d22�r�z&GrammarTests.test_funcdef.<locals>.d22cWsdS)Nr)rKr�rrr�d01v�r�z'GrammarTests.test_funcdef.<locals>.d01v)rrr�r�cWsdS)Nr)rKrLr�rrr�d11v�r�z'GrammarTests.test_funcdef.<locals>.d11vcWsdS)Nr)rKrLr�r�rrr�d21vr�z'GrammarTests.test_funcdef.<locals>.d21vcWsdS)Nr)rKrLr�rrr�d02vr�z'GrammarTests.test_funcdef.<locals>.d02v)rr�r�cWsdS)Nr)rKrLr�r�rrr�d12vr�z'GrammarTests.test_funcdef.<locals>.d12v)r�r�rDcWsdS)Nr)rKrLr�r�r�rrr�d22vr�z'GrammarTests.test_funcdef.<locals>.d22vr�r
sfooz/Bytes should not work as keyword argument namescSs|S)Nr)�keyrrr�pos0key1(r�z+GrammarTests.test_funcdef.<locals>.pos0key1�d)r�)�k2cSs||||fS)Nr)�p1�p2�k1r�rrr�pos2key2*r�z+GrammarTests.test_funcdef.<locals>.pos2key2)r���)r�r�)r�r�c[s|||||fS)Nr)r�r�r�r�Zkwargrrr�pos2key2dict.r�z/GrammarTests.test_funcdef.<locals>.pos2key2dict)r��tokwarg1�tokwarg2)r�r�r�zdef f(*): passzdef f(*,): passzdef f(*, **kwds): passc_s||fS)Nr)r��kwargsrrrrN7sz$GrammarTests.test_funcdef.<locals>.f)r
r.)rr�r�zf(1, x=2, *(3,4), x=5)Z	scrambledZfried)�eggs�spamr�r�z
f(*g(1=2))zf(**g(1=2)))�returncSsdS)Nr)r
rrrrNGr�r�)r
cSsdS)Nr)r
rrrrNIr�cWsdS)Nr)r
rrrrNKr�c[sdS)Nr)r
rrrrNMr�)r.cSsdS)Nr)r
r.rrrrNOr�r.)rLr�cSsdS)Nr)rKrLr�r�rrrrNQr�)rLr�r]�gcWsdS)Nr)rKrLr�r�r]rNr�rrrrNSr��
)�i�j��)rLr�r]r��hr��kr�c_sdS)Nr)rKrLr�r�r]rNr�r�r�r�r�rrrrNVsc@seZdZdd�dd�ZdS)z'GrammarTests.test_funcdef.<locals>.Spamr)�	_Spam__kwcSsdS)Nr)r	r�rrrrN]sz)GrammarTests.test_funcdef.<locals>.Spam.fN)r7r8r9rNrrrr�Spam\sr�c@seZdZdS)z&GrammarTests.test_funcdef.<locals>.HamN)r7r8r9rrrr�Ham_sr�r�cSs|S)Nr)r
rrr�nullcr�z'GrammarTests.test_funcdef.<locals>.nullcSsdS)Nr)r
rrrrNdscs�S)Nrr)�closurerrrNjr�cs�S)Nr)r
)r�rrrNkr�)r�cs�S)Nr)r�)r�rrrNlr�cs�S)Nrr)r�rrrNmr�cSsdS)Nr)rKrrrrNpr�cWsdS)Nr)r�rrrrNqr�c[sdS)Nr)rbrrrrNrr�cWsdS)Nr)rKr�rrrrNsr�c[sdS)Nr)rKrbrrrrNtr�cWsdS)Nr)rLr�rrrrNur�cSsdS)Nr)rLrrrrNvr�c_sdS)Nr)r�rbrrrrNwr�cWsdS)Nr)rKrLr�rrrrNxr�cSsdS)Nr)rKrLrrrrNyr�c_sdS)Nr)rKr�rbrrrrNzr�c_sdS)Nr)rLr�rbrrrrN{r�c[sdS)Nr)rLrbrrrrN|r�c_sdS)Nr)rKrLr�rbrrrrN}r�c[sdS)Nr)rKrLrbrrrrN~r�)r)r)r)r)r)rr)rr)rr)r)r)rr)rr)r)r)r)rr)rr)r)rr)rr)r)rr)rr)r)r
)r)r)r�)r�rD)r�rD)r)r�__code__�co_varnamesr4�	TypeErrorrrrrrrHrUrG�floatrN)r	rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rNr�r�r�r)r�r�test_funcdef�sn







 

























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>rcSsttS)N)rKr�rrrrr��r�cSsdd�dD�S)NcSsg|]}d|k�qS)rr)�.0r
rrr�
<listcomp>�sz?GrammarTests.test_lambdef.<locals>.<lambda>.<locals>.<listcomp>)���r�rrrrrrr��r�rcSs|S)Nr)rVrrrr��r�cSs|�S)Nr)r.rrrr��r�cSs|�S)Nr)r
rrrr��r�rcSs|||S)Nr)r
r.rVrrrr��r�rDr�r�zlambda x: x = 2zlambda (None,): None�)r�cSs|||S)Nr)r
r.r�rrrr��r��r��
cSsdS)Nrr)rKrrrr��r�cWsdS)Nrr)r�rrrr��r�c[sdS)Nrr)rbrrrr��r�cWsdS)Nrr)rKr�rrrr��r�c[sdS)Nrr)rKrbrrrr��r�cWsdS)Nrr)rLr�rrrr��r�cSsdS)Nrr)rLrrrr��r�c_sdS)Nrr)r�rbrrrr��r�cWsdS)Nrr)rKrLr�rrrr��r�cSsdS)Nrr)rKrLrrrr��r�c_sdS)Nrr)rKr�rbrrrr��r�c_sdS)Nrr)rLr�rbrrrr��r�c[sdS)Nrr)rLrbrrrr��r�c_sdS)Nrr)rKrLr�rbrrrr��r�c[sdS)Nrr)rKrLrbrrrr��r�)r)r)rr)r	�l1�l2�l3�l4�l5�l6�l10Zl11Zl12Zl13Zl14Zl15Zl16Zl17Zl18Zl19Zl20Zl21Zl22Zl23Zl24rrr�test_lambdef�s<


zGrammarTests.test_lambdefcCsd}~dd�}|�dS)NrcSs
d}~dS)Nrr)r
rrr�foo�sz*GrammarTests.test_simple_stmt.<locals>.foor)r	r
r�rrr�test_simple_stmt�szGrammarTests.test_simple_stmtc	CsRd}d}d}}}d\}}}d}\}}}\}}}}t|d�t|d�dS)Nr)rrr�)rr)r�r�z	x + 1 = 1z
a + 1 = b + 2)r)	r	r
r.rV�abcrKrLr��xyzrrr�test_expr_stmt�s

zGrammarTests.test_expr_stmtcCs�d}ddddddg}x�|D]�}d�|�}x�|D]�}|�|�}|j|d	��&|�t|��t|�WdQRXWdQRX|�d
d�}|j|d	��&|�td��t|�WdQRXWdQRXq.WqWdS)
N)rPr2z{} fooz{} {{1:foo}}zif 1: {} foozif 1: {} {{1:foo}}zif 1:
    {} foozif 1:
    {} {{1:foo}}zcall to '{}')�sourcer�z(foo.)zinvalid syntax)�formatZsubTest�assertRaisesRegexrr2r#)r	�keywordsZcases�keywordZ
custom_msgZcaser�rrr�(test_former_statements_refer_to_builtins�s$



z5GrammarTests.test_former_statements_refer_to_builtinscCs,dddg}|\}}}|||f}~~~~~dS)Nrrr�r)r	r�r
r.rVr�rrr�
test_del_stmt�s



zGrammarTests.test_del_stmtcCsdS)Nr)r	rrr�test_pass_stmt�szGrammarTests.test_pass_stmtcCsxPqWdS)Nr)r	rrr�test_break_stmt�szGrammarTests.test_break_stmtcCs�d}x|rd}qqWd}x(|s@d}y
wd}Wqd}YqXqW|dkrT|�|�d}x|srd}zwZWdd}XqZW|dkr�|�|�dS)Nrrr!�okz&continue failed to continue inside tryz'continue inside try called except blockzfinally block not called)r)r	r��msgrrr�test_continue_stmt�s,

zGrammarTests.test_continue_stmtcsd�fdd�	}|�dS)Nrrcshd}xD|rH|d7}y$|r*|dkr*|d8}P|d8}wWq�YqXqW|dksZ|dkrd��d�dS)Nrrz1continue then break in try/except in loop broken!)r)Zextra_burning_oil�countZ	big_hippo)r	rr�
test_innersz9GrammarTests.test_break_continue_loop.<locals>.test_inner)rrr)r	r�r)r	r�test_break_continue_loops
z%GrammarTests.test_break_continue_loopcCs*dd�}dd�}|�|�}t|d�dS)NcSsdS)Nrrrrr�g1"r�z$GrammarTests.test_return.<locals>.g1cSsdS)Nrrrrrr�g2#r�z$GrammarTests.test_return.<locals>.g2zclass foo:return 1)r)r	r�r�r
rrr�test_return s
zGrammarTests.test_returncCs:d}x|dkr"|d7}zWdPXqW|�|d�d}x |dkrT|d7}zw6WdPXq6W|�|d�d}x&|dkr�|d7}zddWdPXqhW|�|d�x"dD]}|�|d�zWdPXq�W|�|d�x$dD]}|�|d�zw�WdPXq�W|�|d�x,dD]$}|�|d�zddWdPX�qW|�|d�dS)Nrrr)rr)r)r	r�rrr�test_break_in_finally(sN






z"GrammarTests.test_break_in_finallycCsFdd�}|�|�d�dd�}|�|�d�dd�}|�|�d	�dS)
NcSs
zWddS)Nrrrrrrr�]sz/GrammarTests.test_return_in_finally.<locals>.g1rcSs
zdSdS)Nrr�rrrrrr�dsz/GrammarTests.test_return_in_finally.<locals>.g2r�cSszddWddS)Nrrr�rrrrr�g3ksz/GrammarTests.test_return_in_finally.<locals>.g3r�)r)r	r�r�r�rrr�test_return_in_finally\sz#GrammarTests.test_return_in_finallycCs�dd�}dd�}dd�}dd�}dd�}dd�}t|d�t|d	�d
d�}dd�}t|d�t|d
�dd�}dd�}dd�}dd�}t|d�t|d�t|d�t|d�t|d�t|d�t|d�t|d�t|d�dS)Ncss
dVdS)Nrrrrrrr�tr�z"GrammarTests.test_yield.<locals>.gcssdEdHdS)Nrrrrrrr�ur�css
dV}dS)Nrr)r
rrrr�wr�cssdEdH}dS)Nrr)r
rrrr�xr�css
dVdS)N)rrrrrrrr�zr�css
dV}dS)N)rrr)r
rrrr�{r�zdef g(): yield from (), 1zdef g(): x = yield from (), 1cssddVfdS)Nrrrrrrr��r�cssddEdHfdS)Nrrrrrrrr��r�zdef g(): 1, yield 1zdef g(): 1, yield from ()csstdV�dS)Nr)rNrrrrr��r�csstdVd�dS)Nr)rNrrrrr��r�csstdEdH�dS)Nr)rNrrrrr��r�csstdEdHd�dS)Nrr)rNrrrrr��r�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)r)r	r�rrr�
test_yieldrs2











zGrammarTests.test_yieldcs�dd�}dd�}�fdd�}|dd�|dd�|d	d�|d
d�|dd
�|dd
�|dd�|dd�|dd�|dd�dS)Ncssdd�dVgD�dS)NcSsg|]}|�qSrr)r�r
rrrr��szHGrammarTests.test_yield_in_comprehensions.<locals>.g.<locals>.<listcomp>rrrrrrr��r�z4GrammarTests.test_yield_in_comprehensions.<locals>.gcssdd�dEdHgD�dS)NcSsg|]}|�qSrr)r�r
rrrr��szHGrammarTests.test_yield_in_comprehensions.<locals>.g.<locals>.<listcomp>rrrrrrr��r�c
sv��t|��t|dd�WdQRXddl}|���8|jdtd���t|��t|dd�WdQRXWdQRXdS)Nz
<test string>r2r�error)�category)ZassertWarnsRegex�DeprecationWarningr3�warnings�catch_warnings�filterwarningsr�r)�codeZwarntextr�)r	rr�check�s
z8GrammarTests.test_yield_in_comprehensions.<locals>.checkz 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)r	r�r�r)r	r�test_yield_in_comprehensions�s.	z)GrammarTests.test_yield_in_comprehensionscCsDytd��Wntk
r YnXyt�Wntk
r>YnXdS)Nzjust testing)�RuntimeError�KeyboardInterrupt)r	rrr�
test_raise�szGrammarTests.test_raisecCsdddl}ddl}ddl}ddlm}ddlm}ddlm}m}ddlm}m}ddlm}m}dS)Nr)�time)�path�argv)rr�r�r�)r	rr�r�r�rrr�test_import�szGrammarTests.test_importcCsdS)Nr)r	rrr�test_global�szGrammarTests.test_globalcsd�d���fdd�}dS)NrcsdS)Nrr)r
r.rrrN�sz%GrammarTests.test_nonlocal.<locals>.fr)r	rNr)r
r.r�
test_nonlocal�szGrammarTests.test_nonlocalc
CshyWn,tk
r0}z|�d�Wdd}~XYnXyWn,tk
rb}z|�d�Wdd}~XYnXdS)Nz6'assert True' should not have raised an AssertionErrorz;'assert True, msg' should not have raised an AssertionError)�AssertionErrorr)r	r]rrr�test_assert�szGrammarTests.test_assertFz Won't work if __debug__ is Falsec
Cs�yWn4tk
r8}z|�|jdd�Wdd}~XYnX|�d�yWn4tk
r|}z|�t|j�d�Wdd}~XYnX|�d�dS)Nrr�z%AssertionError not raised by assert 0z+AssertionError not raised by 'assert False')r�rr�rr,)r	r]rrr�testAssert2�s$
$zGrammarTests.testAssert2cCsdS)Nr)r	rrr�test_ifszGrammarTests.test_ifcCsd}d}|�|d�dS)Nrr)r)r	r
rrr�
test_whileszGrammarTests.test_whilecCs�xdD]}qWxdD]
\}}}qWGdd�d�}d}x|d�D]}||}q>W|dkr`|�d�g}xd	D]\}|�|�qjW|�|d
ddg�dS)
N)rrr�rc@s$eZdZdd�Zdd�Zdd�ZdS)z&GrammarTests.test_for.<locals>.SquarescSs||_g|_dS)N)�max�sofar)r	rrrrr<$sz/GrammarTests.test_for.<locals>.Squares.__init__cSs
t|j�S)N)r,r)r	rrr�__len__'r�z.GrammarTests.test_for.<locals>.Squares.__len__cSsVd|kr|jksnt�t|j�}x$||krJ|j�||�|d}q(W|j|S)Nrr)r�
IndexErrorr,r�append)r	r��nrrrrA(s

z2GrammarTests.test_for.<locals>.Squares.__getitem__N)r7r8r9r<rrArrrr�Squares#sr
rr�izfor over growing sequence))r)r)r�rrr�)rrr)r	r�r�r�r
r	r
�resultrrr�test_fors

zGrammarTests.test_forc
Cs�yddWntk
r YnXyddWn>tk
rBYn,tk
rb}zWdd}~XYnYnXyddWntttfk
r�YnXyddWn(tttfk
r�}zWdd}~XYnXzWdXdS)Nrr)rZ�EOFErrorr�)r	r�rrr�test_try9s.zGrammarTests.test_trycCsdS)Nr)r	rrr�
test_suiteOszGrammarTests.test_suitecCsdsdrdsdsdrdS)NrFr)r	rrr�	test_test^s
zGrammarTests.test_testcCs�ddk}ddkrddkrddkr ddkr(ddkr0ddkr8ddkr@ddk	rHddkrPddkrXddkr�dkr�dkr�dkr�dkr�dkr�dkr�dkr�dkr�dk	r�nndS)Nrrr)r	r
rrr�test_comparisonishzGrammarTests.test_comparisoncCsd}d}d}dS)Nrrr)r	r
rrr�test_binary_mask_opszsz!GrammarTests.test_binary_mask_opscCsd}d}d}dS)Nrrrr)r	r
rrr�test_shift_opsszGrammarTests.test_shift_opscCsd}d}d}d}dS)Nrrr�r)r	r
rrr�test_additive_ops�szGrammarTests.test_additive_opscCsd}d}d}d}dS)Nrg�?rgr)r	r
rrr�test_multiplicative_ops�sz$GrammarTests.test_multiplicative_opscCsd}d}d}d}d}dS)Nrr����g�?r)r	r
rrr�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)Nrr�Z01234r�rD���������rr)rr�)rrr�)rrr�cSst|�j|fS)N)rr7)r
rrrr��r�z-GrammarTests.test_selectors.<locals>.<lambda>)r�z[1, (1,), (1, 2), (1, 2, 3)])rr�r��modulesrH�sortrr4)	r	rr�r�r
rKrr��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)Nrrr�rFr�)rFr�r�rDr�)rFr��threeZfourZfiveZsixrr
rjr)r	r
rrr�
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>.BN)r7r8r9rrrr�B�sr!c@seZdZdS)z&GrammarTests.test_classdef.<locals>.B2N)r7r8r9rrrr�B2�sr"c@seZdZdS)z&GrammarTests.test_classdef.<locals>.C1N)r7r8r9rrrr�C1�sr#c@seZdZdS)z&GrammarTests.test_classdef.<locals>.C2N)r7r8r9rrrr�C2�sr$c@seZdZdS)z%GrammarTests.test_classdef.<locals>.DN)r7r8r9rrrr�D�sr%c@s$eZdZdd�Zdd�Zdd�ZdS)z%GrammarTests.test_classdef.<locals>.CcSsdS)Nr)r	rrr�meth1�r�z+GrammarTests.test_classdef.<locals>.C.meth1cSsdS)Nr)r	�argrrr�meth2�r�z+GrammarTests.test_classdef.<locals>.C.meth2cSsdS)Nr)r	r�r�rrr�meth3�r�z+GrammarTests.test_classdef.<locals>.C.meth3N)r7r8r9r&r(r)rrrrrW�srWcSs|S)Nr)r
rrr�class_decorator�r�z3GrammarTests.test_classdef.<locals>.class_decoratorc@seZdZdS)z%GrammarTests.test_classdef.<locals>.GN)r7r8r9rrrr�G�sr+r)	r	r!r"r#r$r%rWr*r+rrr�
test_classdef�szGrammarTests.test_classdefcCs,dddg}|�dd�|D�dddd��dS)Nrrr�cSsi|]}|d|�qS)rr)r�r�rrr�
<dictcomp>�sz/GrammarTests.test_dictcomps.<locals>.<dictcomp>r�)rrr�)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)ANrrr�r�rD�Apple�Banana�Coconutz  Applez Banana zCoco  nut  cSsg|]}|���qSr)�strip)r�rrrrr��sz/GrammarTests.test_listcomps.<locals>.<listcomp>z	Coco  nutcSsg|]}d|�qS)r�r)r�r
rrrr��sr�rr��cSsg|]}|dkr|�qS)rr)r�r
rrrr��scsg|]}�D]}||f�qqSrr)r�r�r)�strsrrr��s)rr0)rr1)rr2)rr0)rr1)rr2)r�r0)r�r1)r�r2)r�r0)r�r1)r�r2)rDr0)rDr1)rDr2cs(g|] }dd��D�D]}||f�qqS)cSsg|]}d|kr|�qS)r	r)r�rNrrrr�sz:GrammarTests.test_listcomps.<locals>.<listcomp>.<listcomp>r)r�r�r)r5rrr�scSsg|]}dd�|��qS)cs�fdd�t�d�D�S)Ncsg|]}�|�qSrr)r�r�)rKrrr�szLGrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>.<locals>.<listcomp>r)�range)rKr)rKrr�r�z8GrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>r)r�r�rrrr�s���@�cSsdd�|D�S)NcSs,g|]$}|dkrd|ko"dkn�qS)rrr�r)r�r
rrrr�	szEGrammarTests.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�||dgD��qS)cSsg|]}|�qSrr)r�r.rrrr�szUGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>.<listcomp>rr)r�r
rrrr�szJGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>)rr�rDrrr�r�rDr�)rr)r	rr�test_nested_front
sz6GrammarTests.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)rr�)rr�)rr�)r�rCcsDg|]<\}}�D].\}}�D] \}}||kr||kr||f�qqqSrr)r�ZsnoZsnameZpnoZpnameZsp_snoZsp_pno)�parts�suppartrrr�'s)r>rA)r>rB)r?rB)r@rD)rr6r)r	r.Zspcsr<r=Z	suppliersr
r)rEr	r5rFr�test_listcomps�sF

 
.

zGrammarTests.test_listcompscs�dd�td�D�}|�t|�dd�td�D��yt|�|�d�Wntk
rZYnXd�y(�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|]}|�qSrr)r�r
rrrr�3sz7GrammarTests.test_genexps.<locals>.<genexpr>.<listcomp>r�N)r6)r�r
rrr�	<genexpr>3sz,GrammarTests.test_genexps.<locals>.<genexpr>rcSsg|]}|�qSrr)r�r
rrrr�4sz-GrammarTests.test_genexps.<locals>.<listcomp>r�z&should produce StopIteration exceptionc3s|]
}�VqdS)Nr)r�r�)rKrrrH=szshould produce TypeErrorcss |]}dD]}||fVq
qdS)�abcdNr)r�r
r.rrrrHCsrIcSsg|]}dD]}||f�qqS)rIr)r�r
r.rrrr�Cscss |]}dD]}||fVq
qdS)�xyNr)r�r
r.rrrrHDsZabcSsg|]}dD]}||f�qqS)rJr)r�r
r.rrrr�DscSsg|]}|�qSrr)r�r
rrrr�Fscss|]
}|VqdS)Nr)r�r
rrrrHGscss|]
}|VqdS)Nr)r�r.rrrrHGscSsg|]}|�qSrr)r�r
rrrr�Hscss|]}|dVqdS)rNr)r�r
rrrrHJscSsg|]}|d�qS)rr)r�r
rrrr�Jscss|]}|dr||VqdS)rNr)r�r
rrrrHKscSsg|]}|dr||�qS)rr)r�r
rrrr�Kscss|]
}|VqdS)Nr)r�r
rrrrHLscss|]
}|VqdS)Nr)r�r.rrrrHLscSsg|]}|�qSrr)r�r
rrrr�Lscss|]
}|VqdS)Nr)r�r
rrrrHMscss|]
}|VqdS)Nr)r�r.rrrrHMscss|]
}|VqdS)Nr)r�rVrrrrHMscSsg|]}|�qSrr)r�r
rrrr�Mscss|]
}|VqdS)Nr)r�r
rrrrHNscSsg|]}|�qSrr)r�r.rrrr�Nscss|]
}|VqdS)Nr)r�rVrrrrHNscSsg|]}|�qSrr)r�r
rrrr�Nscss|]
}|VqdS)TNr)r�r
rrrrHOscss|]
}|VqdS)Nr)r�r.rrrrHOscss|]
}|VqdS)TNr)r�rVrrrrHOscSsg|]}|�qSrr)r�r
rrrr�Oscss|]
}|VqdS)TNr)r�r
rrrrHPscss|]}dr|VqdS)FNr)r�r.rrrrHPscss|]
}|VqdS)TNr)r�rVrrrrHPsrzfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r6r�nextr�
StopIterationr�rH�sumr)r	r�rLr)rKr�test_genexps1s8$$"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|]
}|VqdS)Nr)r�r�rrrrHVsz;GrammarTests.test_comprehension_specials.<locals>.<genexpr>rDFc3s(|] }�rt��D]}||fVqqdS)N)r6)r�r�r�)�tr
rrrHZsTcSs"g|]}td�D]}||f�qqS)rD)r6)r�r�r�rrrr�\sz<GrammarTests.test_comprehension_specials.<locals>.<listcomp>cSs g|]}|dr|dr|�qS)rr�r)r�r
rrrr�`srr�css"|]}|dr|dr|VqdS)rr�Nr)r�r
rrrrHascSsg|]
\}|�qSrr)r�r
rrrr�ds))r�)rD)r�r�r�css|]\}|VqdS)Nr)r�r
rrrrHes))r�)r�)rr�r)r6rr,rH)r	r�r)rOr
r�test_comprehension_specialsTs $z(GrammarTests.test_comprehension_specialsc
Cs�Gdd�dt�}|��WdQRX|��}WdQRX|��
\}}WdQRX|��|��WdQRXWdQRX|��}|��}WdQRXWdQRX|��}|��WdQRXWdQRXdS)Nc@seZdZdd�Zdd�ZdS)z1GrammarTests.test_with_statement.<locals>.managercSsdS)N)rrr)r	rrr�	__enter__isz;GrammarTests.test_with_statement.<locals>.manager.__enter__cWsdS)Nr)r	r�rrr�__exit__ksz:GrammarTests.test_with_statement.<locals>.manager.__exit__N)r7r8r9rQrRrrrr�managerhsrS)�object)r	rSr
r.rrr�test_with_statementgs


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 correctly)rP)r��retrrr�
_checkeval}sz2GrammarTests.test_if_else_expr.<locals>._checkevalcSsg|]}|�r|��qSrr)r�r
rrrr��sz2GrammarTests.test_if_else_expr.<locals>.<listcomp>cSsdS)NTrrrrrr��r�z0GrammarTests.test_if_else_expr.<locals>.<lambda>cSsdS)NFrrrrrr��r�TcSsg|]}|d�r|d��qS)Fr)r�r
rrrr��scSs|rdSdS)NFTr)r
rrrr��r�cSs|rdSdS)NTFr)r
rrrr��r�rrDzcheck 1rzcheck 2r�zcheck 3rr�zcheck 4zcheck 5zcheck 6Fr�r�r�g@)r)r	rWrrr�test_if_else_expr{s$$$"zGrammarTests.test_if_else_exprcCsj|�dd�|�dd�|�dd�|�dddkk�|�ddkdk�|�ddko^dkn�dS)Nr�rFr�)rrZassertFalse)r	rrr�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)r	rkrrr�
__matmul__�sz2GrammarTests.test_matrix_mul.<locals>.M.__matmul__cSs
||_|S)N)�other)r	rkrrr�__imatmul__�sz3GrammarTests.test_matrix_mul.<locals>.M.__imatmul__N)r7r8r9rZr\rrrrrp�srpr�rE)rr[)r	rp�mrrr�test_matrix_mul�s
zGrammarTests.test_matrix_mulcCsxdd�}|�|jd�|�t|jjtj@��dd�}|dd��}|�|j�|�|jd�|�t|jjtj@��dS)	Nc�sdd�}t�IdHdS)NcSsdS)NrrrrrrM�sz8GrammarTests.test_async_await.<locals>.test.<locals>.sum)Zsomeobj)rMrrrrm�sz+GrammarTests.test_async_await.<locals>.testrmcSst|dd�|S)N�_markedT)�setattr)�funcrrr�	decorator�sz0GrammarTests.test_async_await.<locals>.decoratorc�sdS)N�rrrrr�test2�sz,GrammarTests.test_async_await.<locals>.test2rd)	rr7r�boolr��co_flags�inspectZCO_COROUTINEr_)r	rmrbrdrrr�test_async_await�szGrammarTests.test_async_awaitc	sRGdd�dt��Gdd�d����fdd�}|����|��d�WdQRXdS)Nc@seZdZdS)z)GrammarTests.test_async_for.<locals>.DoneN)r7r8r9rrrr�Done�sric@seZdZdd�Zdd�ZdS)z*GrammarTests.test_async_for.<locals>.AItercSs|S)Nr)r	rrr�	__aiter__�sz4GrammarTests.test_async_for.<locals>.AIter.__aiter__c�st�dS)N)�StopAsyncIteration)r	rrr�	__anext__�sz4GrammarTests.test_async_for.<locals>.AIter.__anext__N)r7r8r9rjrlrrrr�AIter�srmc	�s�x,��2y3dH}Wqtk
s"XqYWx0��2y3dH\}}Wq6tk
sTXq6YWx,��2y3dH}Wqhtk
s�XqhYW��dS)N)rk)r�r�)rmrirrr��s $ z(GrammarTests.test_async_for.<locals>.foo)r\r�send)r	r�r)rmrir�test_async_for�s
zGrammarTests.test_async_forc	sRGdd�dt��Gdd�d����fdd�}|����|��d�WdQRXdS)Nc@seZdZdS)z*GrammarTests.test_async_with.<locals>.DoneN)r7r8r9rrrrri�sric@seZdZdd�Zdd�ZdS)z-GrammarTests.test_async_with.<locals>.managerc�sdS)N)rrr)r	rrr�
__aenter__�sz8GrammarTests.test_async_with.<locals>.manager.__aenter__c�sdS)NFr)r	�excrrr�	__aexit__�sz7GrammarTests.test_async_with.<locals>.manager.__aexit__N)r7r8r9rprrrrrrrS�srSc�s,��4IdH�WdQIdHRX��4IdH�}WdQIdHRX��4IdH�
\}}WdQIdHRX��4IdH�&��4IdH�WdQIdHRXWdQIdHRX��4IdH�&}��4IdH�}WdQIdHRXWdQIdHRX��4IdH�&}��4IdH�WdQIdHRXWdQIdHRX��dS)Nr)r
r.)rirSrrr��s      z)GrammarTests.test_async_with.<locals>.foo)r\rrn)r	r�r)rirSr�test_async_with�s
zGrammarTests.test_async_withN)>r7r8r9rCrIrJr^rirqrurwr|r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�unittestZ
skipUnlessrrrrrrrrrrrrrrr r,r/rGrNrPrUrXrYr^rhrorsrrrrrB�st.			\'	4$#

#?#rB�__main__)Ztest.supportrrgrtrZtest.ann_modulernro�collectionsrrmrr"r$ZTestCaserrGrUr:rBr7�mainrrrr�<module>s�