Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib64/python3.7/test/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/test/__pycache__/test_grammar.cpython-37.opt-1.pyc

B

� f��(@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�6/opt/alt/python37/lib64/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����	Z0x)�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.r0r5rrrr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)r6r7r8r;r?r@rrrrr9�sr9c@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_lstrErrr�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)rOZno_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)	r6r7r8rF�__annotations__rr3�zr;rrrr�CJs
rV)rRrc@seZdZUde_edS)z9GrammarTests.test_var_annot_basic_semantics.<locals>.CBadrN)r6r7r8Zno_such_name_definedrSrFrrrr�CBadRs
rWc@s eZdZUeed<ge_edS)z:GrammarTests.test_var_annot_basic_semantics.<locals>.Cbad2r
N)r6r7r8rFrTr
r-rGrrrr�Cbad2Us
rX)
r�ZeroDivisionErrorZno_nameZdoes_not_existr$rrT�UnboundLocalError�	ExceptionZassertIsrrFr3)	r	rMrNrPrQ�erVrWrXrrr�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)NrT)r9)�metacls�name�bases�kwdsrrr�__prepare__[szJGrammarTests.test_var_annot_metaclass_semantics.<locals>.CMeta.__prepare__N)r6r7r8�classmethodrbrrrr�CMetaZsrdc@seZdZUded<dS)z;GrammarTests.test_var_annot_metaclass_semantics.<locals>.CC�ANNOTZXXN)r6r7r8rTrrrr�CC^s
rf)�	metaclassZxxre)rrrT)r	rdrfrrr�"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-rM�{)Z123�o)r�AttributeErrorrO�testrTr�
ann_modulerFr3�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_annrC)Ztest.ann_module3rqrrrsrr$)r	rqrrrsrrr�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
rTr)rr
)r1rrFr�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)	NrTz'X: int; Z: str = "Z"; (w): complex = 1jr
rU�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r@�szAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__getitem__N)r6r7r8r;r?r@r)rxrr�CNS2�sryz
x: int = 1)r9r1rrFr3rru)r	�nsryr)rxr�test_var_annot_custom_mapss

	z'GrammarTests.test_var_annot_custom_mapscsHt��d�i�G��fdd�d�}tdi|��|��ddt�dS)NrTcs,eZdZ�fdd�Z�fdd�Zdd�ZdS)z1GrammarTests.test_var_annot_refleak.<locals>.CNS2csd�i|_dS)NrT)r:)r	)�cnsrrr;�sz:GrammarTests.test_var_annot_refleak.<locals>.CNS2.__init__cs||j|<|�|<dS)N)r:)r	r=r>)rxrrr?�s
z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__setitem__cSs
|j|S)N)r:)r	r=rrrr@�sz=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__getitem__N)r6r7r8r;r?r@r)r|rxrrry�sryzX: strr
)r9r1rr3)r	ryr)r|rxr�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�rz%GrammarTests.test_funcdef.<locals>.f2cSsdS)Nr)�two�	argumentsrrr�f3�rz%GrammarTests.test_funcdef.<locals>.f3)r�)r�r�cSsdS)Nr)Zone_argrrr�a1�rz%GrammarTests.test_funcdef.<locals>.a1cSsdS)Nr)r��argsrrr�a2�rz%GrammarTests.test_funcdef.<locals>.a2cWsdS)Nr)�restrrr�v0�rz%GrammarTests.test_funcdef.<locals>.v0cWsdS)Nr)rJr�rrr�v1�rz%GrammarTests.test_funcdef.<locals>.v1cWsdS)Nr)rJrKr�rrr�v2�rz%GrammarTests.test_funcdef.<locals>.v2rr��rC���rrcSsdS)Nr)rJrrr�d01�rz&GrammarTests.test_funcdef.<locals>.d01)rrJcSsdS)Nr)rJrKrrr�d11�rz&GrammarTests.test_funcdef.<locals>.d11rKcSsdS)Nr)rJrK�crrr�d21�rz&GrammarTests.test_funcdef.<locals>.d21)rrr�)rr�)r�r�cSsdS)Nr)rJrKrrr�d02�rz&GrammarTests.test_funcdef.<locals>.d02)rr)r)rJrKcSsdS)Nr)rJrKr�rrr�d12�rz&GrammarTests.test_funcdef.<locals>.d12cSsdS)Nr)rJrKr��drrr�d22�rz&GrammarTests.test_funcdef.<locals>.d22cWsdS)Nr)rJr�rrr�d01v�rz'GrammarTests.test_funcdef.<locals>.d01v)rrr�r�cWsdS)Nr)rJrKr�rrr�d11v�rz'GrammarTests.test_funcdef.<locals>.d11vcWsdS)Nr)rJrKr�r�rrr�d21vrz'GrammarTests.test_funcdef.<locals>.d21vcWsdS)Nr)rJrKr�rrr�d02vrz'GrammarTests.test_funcdef.<locals>.d02v)rr�r�cWsdS)Nr)rJrKr�r�rrr�d12vrz'GrammarTests.test_funcdef.<locals>.d12v)r�r�rCcWsdS)Nr)rJrKr�r�r�rrr�d22vrz'GrammarTests.test_funcdef.<locals>.d22vr�r
sfooz/Bytes should not work as keyword argument namescSs|S)Nr)�keyrrr�pos0key1(rz+GrammarTests.test_funcdef.<locals>.pos0key1�d)r�)�k2cSs||||fS)Nr)�p1�p2�k1r�rrr�pos2key2*rz+GrammarTests.test_funcdef.<locals>.pos2key2)r���)r�r�)r�r�c[s|||||fS)Nr)r�r�r�r�Zkwargrrr�pos2key2dict.rz/GrammarTests.test_funcdef.<locals>.pos2key2dict)r��tokwarg1�tokwarg2)r�r�r�zdef f(*): passzdef f(*,): passzdef f(*, **kwds): passc_s||fS)Nr)r��kwargsrrrrM7sz$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rMGrr�)r
cSsdS)Nr)r
rrrrMIrcWsdS)Nr)r
rrrrMKrc[sdS)Nr)r
rrrrMMr)r-cSsdS)Nr)r
r-rrrrMOrr-)rKr�cSsdS)Nr)rJrKr�r�rrrrMQr)rKr�r\�gcWsdS)Nr)rJrKr�r�r\rMr�rrrrMSr�
)�i�j��)rKr�r\r��hr��kr�c_sdS)Nr)rJrKr�r�r\rMr�r�r�r�r�rrrrMVsc@seZdZdd�dd�ZdS)z'GrammarTests.test_funcdef.<locals>.Spamr)�	_Spam__kwcSsdS)Nr)r	r�rrrrM]sz)GrammarTests.test_funcdef.<locals>.Spam.fN)r6r7r8rMrrrr�Spam\sr�c@seZdZdS)z&GrammarTests.test_funcdef.<locals>.HamN)r6r7r8rrrr�Ham_sr�r�cSs|S)Nr)r
rrr�nullcrz'GrammarTests.test_funcdef.<locals>.nullcSsdS)Nr)r
rrrrMdscs�S)Nrr)�closurerrrMjrcs�S)Nr)r
)r�rrrMkr)r�cs�S)Nr)r�)r�rrrMlrcs�S)Nrr)r�rrrMmrcSsdS)Nr)rJrrrrMprcWsdS)Nr)r�rrrrMqrc[sdS)Nr)rarrrrMrrcWsdS)Nr)rJr�rrrrMsrc[sdS)Nr)rJrarrrrMtrcWsdS)Nr)rKr�rrrrMurcSsdS)Nr)rKrrrrMvrc_sdS)Nr)r�rarrrrMwrcWsdS)Nr)rJrKr�rrrrMxrcSsdS)Nr)rJrKrrrrMyrc_sdS)Nr)rJr�rarrrrMzrc_sdS)Nr)rKr�rarrrrM{rc[sdS)Nr)rKrarrrrM|rc_sdS)Nr)rJrKr�rarrrrM}rc[sdS)Nr)rJrKrarrrrM~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�rC)r�rC)r)r�__code__�co_varnamesr3�	TypeErrorrrrrrrGrTrF�floatrM)r	r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rMr�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>�rz+GrammarTests.test_lambdef.<locals>.<lambda>rcSsttS)N)rJr�rrrrr��rcSsdd�dD�S)NcSsg|]}d|k�qS)rr)�.0r
rrr�
<listcomp>�sz?GrammarTests.test_lambdef.<locals>.<lambda>.<locals>.<listcomp>)���r�rrrrrrr��rrcSs|S)Nr)rUrrrr��rcSs|�S)Nr)r-rrrr��rcSs|�S)Nr)r
rrrr��rrcSs|||S)Nr)r
r-rUrrrr��rrCr�r�zlambda x: x = 2zlambda (None,): None�)r�cSs|||S)Nr)r
r-r�rrrr��r�r��
cSsdS)Nrr)rJrrrr��rcWsdS)Nrr)r�rrrr��rc[sdS)Nrr)rarrrr��rcWsdS)Nrr)rJr�rrrr��rc[sdS)Nrr)rJrarrrr��rcWsdS)Nrr)rKr�rrrr��rcSsdS)Nrr)rKrrrr��rc_sdS)Nrr)r�rarrrr��rcWsdS)Nrr)rJrKr�rrrr��rcSsdS)Nrr)rJrKrrrr��rc_sdS)Nrr)rJr�rarrrr��rc_sdS)Nrr)rKr�rarrrr��rc[sdS)Nrr)rKrarrrr��rc_sdS)Nrr)rJrKr�rarrrr��rc[sdS)Nrr)rJrKrarrr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-rU�abcrJrKr��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)rOr1z{} 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�assertRaisesRegexrr1r")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-rUr�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"rz$GrammarTests.test_return.<locals>.g1cSsdS)Nrrrrrr�g2#rz$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�trz"GrammarTests.test_yield.<locals>.gcssdEdHdS)Nrrrrrrr�urcss
dV}dS)Nrr)r
rrrr�wrcssdEdH}dS)Nrr)r
rrrr�xrcss
dVdS)N)rrrrrrrr�zrcss
dV}dS)N)rrr)r
rrrr�{rzdef g(): yield from (), 1zdef g(): x = yield from (), 1cssddVfdS)Nrrrrrrr��rcssddEdHfdS)Nrrrrrrrr��rzdef g(): 1, yield 1zdef g(): 1, yield from ()csstdV�dS)Nr)rMrrrrr��rcsstdVd�dS)Nr)rMrrrrr��rcsstdEdH�dS)Nr)rMrrrrr��rcsstdEdHd�dS)Nrr)rMrrrrr��rzdef 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��rz4GrammarTests.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��rc
sv��t|��t|dd�WdQRXddl}|���8|jdtd���t|��t|dd�WdQRXWdQRXdS)Nz
<test string>r1r�error)�category)ZassertWarnsRegex�DeprecationWarningr2�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rM�sz%GrammarTests.test_nonlocal.<locals>.fr)r	rMr)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__'rz.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r@(s

z2GrammarTests.test_for.<locals>.Squares.__getitem__N)r6r7r8r;rr@rrrr�Squares#sr	rr�izfor over growing sequence))r)r)r�rrr�)rrr)r	r�r�r�r	rr
�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)rY�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�rC���������rr)rr�)rrr�)rrr�cSst|�j|fS)N)rr6)r
rrrr��rz-GrammarTests.test_selectors.<locals>.<lambda>)r�z[1, (1,), (1, 2), (1, 2, 3)])rr�r��modulesrG�sortrr3)	r	rr�r�r
rJrr��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�rEr�)rEr�r�rCr�)rEr��threeZfourZfiveZsixrr
rir)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)r6r7r8rrrr�B�sr c@seZdZdS)z&GrammarTests.test_classdef.<locals>.B2N)r6r7r8rrrr�B2�sr!c@seZdZdS)z&GrammarTests.test_classdef.<locals>.C1N)r6r7r8rrrr�C1�sr"c@seZdZdS)z&GrammarTests.test_classdef.<locals>.C2N)r6r7r8rrrr�C2�sr#c@seZdZdS)z%GrammarTests.test_classdef.<locals>.DN)r6r7r8rrrr�D�sr$c@s$eZdZdd�Zdd�Zdd�ZdS)z%GrammarTests.test_classdef.<locals>.CcSsdS)Nr)r	rrr�meth1�rz+GrammarTests.test_classdef.<locals>.C.meth1cSsdS)Nr)r	�argrrr�meth2�rz+GrammarTests.test_classdef.<locals>.C.meth2cSsdS)Nr)r	r�r�rrr�meth3�rz+GrammarTests.test_classdef.<locals>.C.meth3N)r6r7r8r%r'r(rrrrrV�srVcSs|S)Nr)r
rrr�class_decorator�rz3GrammarTests.test_classdef.<locals>.class_decoratorc@seZdZdS)z%GrammarTests.test_classdef.<locals>.GN)r6r7r8rrrr�G�sr*r)	r	r r!r"r#r$rVr)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�rC�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)rr/)rr0)rr1)rr/)rr0)rr1)r�r/)r�r0)r�r1)r�r/)r�r0)r�r1)rCr/)rCr0)rCr1cs(g|] }dd��D�D]}||f�qqS)cSsg|]}d|kr|�qS)rr)r�rMrrrr�sz:GrammarTests.test_listcomps.<locals>.<listcomp>.<listcomp>r)r�r�r)r4rrr�scSsg|]}dd�|��qS)cs�fdd�t�d�D�S)Ncsg|]}�|�qSrr)r�r�)rJrrr�szLGrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>.<locals>.<listcomp>r)�range)rJr)rJrr�rz8GrammarTests.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�rCrrr�r�rCr�)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�rBcsDg|]<\}}�D].\}}�D] \}}||kr||kr||f�qqqSrr)r�ZsnoZsnameZpnoZpnameZsp_snoZsp_pno)�parts�suppartrrr�'s)r=r@)r=rA)r>rA)r?rC)rr5r)r	r-Zspcsr;r<Z	suppliersr
r)rDr	r4rEr�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)r5)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�)rJrrrG=szshould produce TypeErrorcss |]}dD]}||fVq
qdS)�abcdNr)r�r
r-rrrrGCsrHcSsg|]}dD]}||f�qqS)rHr)r�r
r-rrrr�Cscss |]}dD]}||fVq
qdS)�xyNr)r�r
r-rrrrGDsZabcSsg|]}dD]}||f�qqS)rIr)r�r
r-rrrr�DscSsg|]}|�qSrr)r�r
rrrr�Fscss|]
}|VqdS)Nr)r�r
rrrrGGscss|]
}|VqdS)Nr)r�r-rrrrGGscSsg|]}|�qSrr)r�r
rrrr�Hscss|]}|dVqdS)rNr)r�r
rrrrGJscSsg|]}|d�qS)rr)r�r
rrrr�Jscss|]}|dr||VqdS)rNr)r�r
rrrrGKscSsg|]}|dr||�qS)rr)r�r
rrrr�Kscss|]
}|VqdS)Nr)r�r
rrrrGLscss|]
}|VqdS)Nr)r�r-rrrrGLscSsg|]}|�qSrr)r�r
rrrr�Lscss|]
}|VqdS)Nr)r�r
rrrrGMscss|]
}|VqdS)Nr)r�r-rrrrGMscss|]
}|VqdS)Nr)r�rUrrrrGMscSsg|]}|�qSrr)r�r
rrrr�Mscss|]
}|VqdS)Nr)r�r
rrrrGNscSsg|]}|�qSrr)r�r-rrrr�Nscss|]
}|VqdS)Nr)r�rUrrrrGNscSsg|]}|�qSrr)r�r
rrrr�Nscss|]
}|VqdS)TNr)r�r
rrrrGOscss|]
}|VqdS)Nr)r�r-rrrrGOscss|]
}|VqdS)TNr)r�rUrrrrGOscSsg|]}|�qSrr)r�r
rrrr�Oscss|]
}|VqdS)TNr)r�r
rrrrGPscss|]}dr|VqdS)FNr)r�r-rrrrGPscss|]
}|VqdS)TNr)r�rUrrrrGPsrzfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r5r�nextr�
StopIterationr�rG�sumr)r	r�rKr)rJr�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rGVsz;GrammarTests.test_comprehension_specials.<locals>.<genexpr>rCFc3s(|] }�rt��D]}||fVqqdS)N)r5)r�r�r�)�tr
rrrGZsTcSs"g|]}td�D]}||f�qqS)rC)r5)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rGascSsg|]
\}|�qSrr)r�r
rrrr�ds))r�)rC)r�r�r�css|]\}|VqdS)Nr)r�r
rrrrGes))r�)r�)rr�r)r5rr+rG)r	r�r)rNr
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)r6r7r8rPrQrrrr�managerhsrR)�object)r	rRr
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)rO)r�Zretrrr�
_checkeval}sz2GrammarTests.test_if_else_expr.<locals>._checkevalcSsg|]}|�r|��qSrr)r�r
rrrr��sz2GrammarTests.test_if_else_expr.<locals>.<listcomp>cSsdS)NTrrrrrr��rz0GrammarTests.test_if_else_expr.<locals>.<lambda>cSsdS)NFrrrrrr��rTcSsg|]}|d�r|d��qS)Fr)r�r
rrrr��scSs|rdSdS)NFTr)r
rrrr��rcSs|rdSdS)NTFr)r
rrrr��rrrCzcheck 1rzcheck 2r�zcheck 3rr�zcheck 4zcheck 5zcheck 6Fr�r�r�g@)r)r	rUrrr�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	rjrrr�
__matmul__�sz2GrammarTests.test_matrix_mul.<locals>.M.__matmul__cSs
||_|S)N)�other)r	rjrrr�__imatmul__�sz3GrammarTests.test_matrix_mul.<locals>.M.__imatmul__N)r6r7r8rXrZrrrrro�sror�rD)rrY)r	ro�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rL�sz8GrammarTests.test_async_await.<locals>.test.<locals>.sum)Zsomeobj)rLrrrrl�sz+GrammarTests.test_async_await.<locals>.testrlcSst|dd�|S)N�_markedT)�setattr)�funcrrr�	decorator�sz0GrammarTests.test_async_await.<locals>.decoratorc�sdS)N�rrrrr�test2�sz,GrammarTests.test_async_await.<locals>.test2rb)	rr6r�boolr��co_flags�inspectZCO_COROUTINEr])r	rlr`rbrrr�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)r6r7r8rrrr�Done�srgc@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)r6r7r8rhrjrrrr�AIter�srkc	�s�x,��2y3dH}Wqtk
s"XqYWx0��2y3dH\}}Wq6tk
sTXq6YWx,��2y3dH}Wqhtk
s�XqhYW��dS)N)ri)r�r�)rkrgrrr��s $ z(GrammarTests.test_async_for.<locals>.foo)r[r�send)r	r�r)rkrgr�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)r6r7r8rrrrrg�srgc@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)r6r7r8rnrprrrrrR�srRc�s,��4IdH�WdQIdHRX��4IdH�}WdQIdHRX��4IdH�
\}}WdQIdHRX��4IdH�&��4IdH�WdQIdHRXWdQIdHRX��4IdH�&}��4IdH�}WdQIdHRXWdQIdHRX��4IdH�&}��4IdH�WdQIdHRXWdQIdHRX��dS)Nr)r
r-)rgrRrrr��s      z)GrammarTests.test_async_with.<locals>.foo)r[rrl)r	r�r)rgrRr�test_async_with�s
zGrammarTests.test_async_withN)>r6r7r8rBrHrIr]rhrprtrvr{r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��unittestZ
skipUnlessrrrrr
rrrrrrrrrrr+r.rFrMrOrTrVrWr\rfrmrqrrrrrA�st.			\'	4$#

#?#rA�__main__)Ztest.supportrrerrrZtest.ann_modulermrn�collectionsrrlrr!r#ZTestCaserrFrTr9rAr6�mainrrrr�<module>s�