Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_grammar.cpython-310.opt-2.pyc

o

0�i��@s�UddlmZddlmZddlmZddlZddlZddlZddlZddlTddl	m
Z
ddlZddlm
Z
ddlmZddlZgd�Zgd	�ZGd
d�dej�Zeed<Gd
d�d�ZGdd�dej�Zedkrpe��dSdS)���check_syntax_error)�
import_helper��check_syntax_warningN)�*)�ChainMap)�ann_module2)Z0_0_0Z4_2Z1_0000_0000Z0b1001_0100Z0xffff_ffffZ0o5_7_7z	1_00_00.5z1_00_00.5e5Z1_00_00e5_1Z1e1_0z.1_4z.1_4e1Z0b_0Z0x_fZ0o_5Z1_00_00jz
1_00_00.5jZ1_00_00e5_1jz.1_4jz(1_2.5+3_3j)z(.5_6j))(Z0_Z42_z1.4j_Z0x_�0b1_Z0xf_Z0o5_z
0 if 1_Else 1Z0_b0Z0_xfZ0_o5Z0_7Z09_99Z	4_______2z0.1__4z0.1__4jZ0b1001__0100Z0xffff__ffffZ0x___Z0o5__77Z1e1__0Z1e1__0jz1_.4z1_.4jz1._4z1._4jz._5z._5jz1.0e+_1z1.0e+_1jz1.4_jz1.4e5_jZ1_e1z1.4_e1z1.4_e1jZ1e_1z1.4e_1z1.4e_1jz
(1+1.5_j_)z	(1+1.5_j)c@speZdZddlmZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
TokenTestsrrcCs(d}|�|dd�d}|�|dd�dS)N�zbackslash for line continuationrzbackslash ending comment��assertEqual��self�x�r�8/opt/alt/python310/lib64/python3.10/test/test_grammar.py�test_backslashlszTokenTests.test_backslashc	Cs`|�td�td��|�dd�|�dd�|�dd�|�dd�|�ttd�ddlm}|dkrk|�dd�|�ddk�|�ddk�|�ddk�d	D]}zt|�}WqPtyh|�	d
|�YqPwdS|dkr�|�dd�|�d
dk�|�d
dk�|�ddk�dD]}zt|�}Wq�ty�|�	d
|�Yq�wdS|�	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_integersvs@����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_floatscCsft���t�dt�|�td�d�|�td�d�Wd�n1s%wY|�ttd�dS)N�ignorez1 if 1else 0�z1 if 0else 0rz0 if 1Else 0)�warnings�catch_warnings�simplefilter�DeprecationWarningrrrr�rrrr� test_float_exponent_tokenization�s
�z+TokenTests.test_float_exponent_tokenizationc	CsPtD]}|�t|�t|�dd���qtD]	}|�tt|�q|�ttd�dS)N�_�Z_0)�VALID_UNDERSCORE_LITERALSrr�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_2Z0b2r
zinvalid 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_literalsc	sd�fdd�	}dD]r}t|dd�||�d�|dkd	�||�d
�|dkd	�||�d��||�d
��t���t�ddt�||�d��Wd�n1sRwY||�d��|d|�d�|dkd	�|d|�d��||�d�dd	�q	|d�|d�|d�dS)NFc
s��j|d��n|rAtjdd��#}��t��t|dd�Wd�n1s&wYWd�n1s5wY��|g�n#��t��t|dd�Wd�n1sWwYWd�dSWd�dSWd�dS1swwYdS)N)�exprT)�record�
<testcase>r)	�subTestr(r)rr�compilerZassertWarnsr+)�test�error�wr,rrr6�s"������"�z8TokenTests.test_end_of_numerical_literals.<locals>.check)�0xfZ0o7Z0b1�9�0z1.Z1e3Z1jr:rzand xr@)r>zor xrBzin xznot in xr&�"is" with a literalzis xzif x else yzx if zelse y�[zfor x in ()]�spamTz[0x1ffor x in ()]z[0x1for x in ()]z[0xfor x in ()]�F)r<r(r)�filterwarnings�
SyntaxWarning)rr6Znumrr,r�test_end_of_numerical_literals�s(
��z)TokenTests.test_end_of_numerical_literalscCs
d}d}|�t|�dko||k�d}d}|�t|�dko&||ko&t|�dk�d}d}|�t|�dko=||ko=t|�dk�d}d}|�t|�d	koN||k�d
}d
}|�t|�d	ko_||k�d}d}|�||�d}|�||�d}|�||�d}|�||�dS)Nr/r�'r'�'�"�"zdoesn't "shrink" does it�zdoes "shrink" doesn't itz2
The "quick"
brown fox
jumps over
the 'lazy' dog.
)r�len�ordr�rr�yrrr�test_string_literals�s$"..zTokenTests.test_string_literalscCs$d}|�|tu�|�ttd�dS)N.z.. .)r�Ellipsisrrrrrrr�
test_ellipsisszTokenTests.test_ellipsisc	CsZd}|D]&}|�t��}t|dd�Wd�n1swY|�dt|j��qdS)N)zdef foo(z	
def foo(z	def foo(
z<test>�execzwas never closed)rrr<ZassertIn�strZ	exception)rZsamplesr"�cmrrr�test_eof_error$s��zTokenTests.test_eof_errorN)�__name__�
__module__�__qualname__�test.supportrrr#r$r%r-r4r7rIrSrUrYrrrrrhs
$
(rZvar_annot_globalc@�$eZdZdd�Zdd�Zdd�ZdS)�CNScC�
i|_dS�N��_dctr,rrr�__init__0�
zCNS.__init__cCs||j|��<dSra)rc�lower�r�item�valuerrr�__setitem__2szCNS.__setitem__cC�
|j|Srarb�rrhrrr�__getitem__4rezCNS.__getitem__N�rZr[r\rdrjrmrrrrr_/sr_c@sLeZdZddlmZddlmZddlmZdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�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�Z d7d8�Z!d9d:�Z"d;d<�Z#d=d>�Z$d?d@�Z%dAdB�Z&dCdD�Z'dEdF�Z(dGdH�Z)dIdJ�Z*e+�,dKdL�dMdN��Z-dOdP�Z.dQdR�Z/dSdT�Z0dUdV�Z1dWdX�Z2dYdZ�Z3d[d\�Z4d]d^�Z5d_d`�Z6dadb�Z7dcdd�Z8dedf�Z9dgdh�Z:didj�Z;dkdl�Z<dmdn�Z=dodp�Z>dqdr�Z?dsdt�Z@dudv�ZAdwdx�ZBdydz�ZCd{d|�ZDd}d~�ZEdd��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�S)��GrammarTestsrrr)�check_no_warningscCstd�}dS)Nz	1, 0 or 1)rrrrr�test_eval_inputG�zGrammarTests.test_eval_inputcCs@d}dg}dd�}ttgdd||�d<|�|dg�dS)N��*cS�dS�Nr'rrrrr�oneP�z/GrammarTests.test_var_annot_basics.<locals>.onerr')�int�listr)rZvar1Zmy_lstrwrrr�test_var_annot_basicsKs
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
rr,rrr�test_var_annot_syntax_errorsWs







z)GrammarTests.test_var_annot_syntax_errorsc	
Cs�|�t��ddtt<Wd�n1swY|�t��dtt<Wd�n1s/wYdd�}|�|ji�dd�}|�dd�}|�t��|�Wd�n1s]wYd	d
�}z|�Wnty�}z|�	t
|�t�WYd}~nd}~wwGdd�d�}|�|jttd
��|�t��Gdd�d�}Wd�n1s�wY|�t��Gdd�d|�}Wd�dS1s�wYdS)Nr'rcSsd}dt_|S)NZHello�r'r��a�b)�strrr�ftsz6GrammarTests.test_var_annot_basic_semantics.<locals>.fcS�dSrarrrrr�f_OKy�z9GrammarTests.test_var_annot_basic_semantics.<locals>.f_OKcSst|�dSra��print�rrrr�fbad|rrz9GrammarTests.test_var_annot_basic_semantics.<locals>.fbadcSstt�dSra)r�Zno_such_globalrrrr�f2bad�rrz:GrammarTests.test_var_annot_basic_semantics.<locals>.f2badc@s.eZdZUeed<dZeed<dZdd�ZdS)z6GrammarTests.test_var_annot_basic_semantics.<locals>.C�_C__foo�attrr"rcSs
||_dSrar�rrrrrd�rez?GrammarTests.test_var_annot_basic_semantics.<locals>.C.__init__N)	rZr[r\ry�__annotations__r"rW�zrdrrrr�C�s

r�)r�r"c@seZdZUde_edS)z9GrammarTests.test_var_annot_basic_semantics.<locals>.CBadrN)rZr[r\Zno_such_name_definedr�ryrrrr�CBad�s
r�c@s eZdZUeed<ge_edS)z:GrammarTests.test_var_annot_basic_semantics.<locals>.Cbad2rN)rZr[r\ryr�rrRrzrrrr�Cbad2�s
r�)
r�ZeroDivisionErrorZno_nameZdoes_not_existr3rr��UnboundLocalError�	ExceptionZassertIsrryrW)	rr�r�r�r��er�r�r�rrr�test_var_annot_basic_semanticsks:�
��
���"�z+GrammarTests.test_var_annot_basic_semanticscCs�Gdd�d�}Gdd�d|�}Gdd�d|�}Gdd�d�}Gd	d
�d
||�}Gdd�d||�}|�|jd
ti�|�|ji�|�|jd
ti�|�|jdti�|�|ji�|�|ji�dS)Nc@�eZdZUeed<dS)z4GrammarTests.test_annotations_inheritance.<locals>.Ar�N�rZr[r\ryr�rrrr�A��
r�c@�eZdZdS)z4GrammarTests.test_annotations_inheritance.<locals>.BN�rZr[r\rrrr�B��r�c@r�)z4GrammarTests.test_annotations_inheritance.<locals>.Cr�N)rZr[r\rWr�rrrrr��r�r�c@r�)z4GrammarTests.test_annotations_inheritance.<locals>.D�attr2Nr�rrrr�D�r�r�c@r�)z4GrammarTests.test_annotations_inheritance.<locals>.ENr�rrrr�E�r�r�c@r�)z4GrammarTests.test_annotations_inheritance.<locals>.FNr�rrrr�F�r�r�r�r�)rr�ryrW)rr�r�r�r�r�r�rrr�test_annotations_inheritance�sz)GrammarTests.test_annotations_inheritancecCs8Gdd�dt�}Gdd�d|d�}|�|jdd�dS)Nc@seZdZedd��ZdS)z>GrammarTests.test_var_annot_metaclass_semantics.<locals>.CMetac[s
dt�iS�Nr�)r_)�metacls�name�bases�kwdsrrr�__prepare__��
zJGrammarTests.test_var_annot_metaclass_semantics.<locals>.CMeta.__prepare__N)rZr[r\�classmethodr�rrrr�CMeta�sr�c@seZdZUded<dS)z;GrammarTests.test_var_annot_metaclass_semantics.<locals>.CC�ANNOTZXXN)rZr[r\r�rrrr�CC�r�r�)�	metaclassZxxr�)rrr�)rr�r�rrr�"test_var_annot_metaclass_semantics�sz/GrammarTests.test_var_annot_metaclass_semanticsc	Cs^|�tji�|�tjdtttjttfttBd��|�tj	jdt
d��|�tji�dS)Nr)r'rrRr��u�{)Z123�o)rr=r��
ann_moduleryrW�typing�Tuple�float�Mrr	r,rrr�test_var_annot_module_semantics�s�
�z,GrammarTests.test_var_annot_module_semanticscCs�t�d�}|�t��|��Wd�n1swY|�t��|��Wd�n1s2wY|�t��|�d�Wd�dS1sMwYdS)Nztest.ann_module3rs)rZimport_fresh_modulerr3Z	f_bad_annZ	g_bad_annZ	D_bad_ann)rZann_module3rrr�test_var_annot_in_module�s

�
�"�z%GrammarTests.test_var_annot_in_modulecCsbi}i}td||�|�|ddtd��|�t��
|dWd�dS1s*wYdS)Nz.'docstring'
__annotations__[1] = 2
x: int = 5
r�r)r'r)rVrryr�KeyError)rZgnsZlnsrrr�test_var_annot_simple_exec�s�
"�z'GrammarTests.test_var_annot_simple_execcs�dt�i}td|�|�|ddt�|�|ddt�|�t��|ddWd�n1s4wYi�G�fdd�d�}tdi|��|��ddt�dS)	Nr�z'X: int; Z: str = "Z"; (w): complex = 1jrr�r?cs(eZdZdd�Z�fdd�Zdd�ZdS)z5GrammarTests.test_var_annot_custom_maps.<locals>.CNS2cSr`rarbr,rrrrd�rez>GrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__init__c�||j|<|�|<dSrarbrg��	nonloc_nsrrrj��
zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__setitem__cSrkrarbrlrrrrm�rezAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__getitem__Nrnrr�rr�CNS2�sr�z
x: int = 1)r_rVrryrWrr�)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)Nr�cs,eZdZ�fdd�Z�fdd�Zdd�ZdS)z1GrammarTests.test_var_annot_refleak.<locals>.CNS2csd�i|_dSr�rbr,)�cnsrrrd��z:GrammarTests.test_var_annot_refleak.<locals>.CNS2.__init__cr�rarbrgr�rrrj�r�z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__setitem__cSrkrarbrlrrrrm�rez=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__getitem__Nrnr�r�r�rrr��sr�zX: strr)r_rVrrW)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 = yieldr�r'�r��rs)rr��cr�zx: Tuple[int, ...] = a,*b,c�r'rr�r�rs)rVrrzr�r�)rr�Zstmtrrr�test_var_annot_rhs�s


zGrammarTests.test_var_annot_rhscs\
dd�}|�|d�|dii��dd�}dd�}|�|jjd�|�|jjd	�d
d�}dd
�}dd�}dd�}dd�}|�|d�|d�|dd�|dd�|�|d�|d�|dd�|dddddddddd�
|d�|d�|dd�|ddd�|dddddddddd�
|dd�|ddd�|dddd�|dddddddddd�
d dd�}	|	�|	d�|	d �|	gp�dg�|	gd�io�d�Rii��|	did!di��|	did!dip�i��d d"d#�}
|
d�|
dd�|
d id$di��d d%d&�}|dd�|ddd�|d'�|dgd(�R�|ddgd)�R�|d-id*di��d-d+d,�}|�|d�|dd�|d-�|dgd.�R�|d id$di��|diddd/���d-d0d1�}
|
d�|
dd�|
ddd�d-d2d3�}|dd�|ddd�|dddd�d d4d5�}|�|d�|dd�|d6�|d �|did!di��d d7d8�}|d�|dd�|ddd�d d9d:�}|dd�|ddd�|dddd�|d6�|d-id*di��d-d;d<�}|�|d�|dd�|ddd�|dgd=�R�|diddd/���d-d>d?�}|d�|dd�|ddd�|dddd�|d6�|ddgd@�R�|dgd.�Rid*di��d-dAdB�}|dd�|ddd�|dddd�|ddddd�|d6�|ddgd@�R�|dgd(�RidCdi��t���)t�dDt�ztd�idFdi��Wn
t�y�Ynw|�	dG�Wd�n	1�s�wYdHdI�}|dJdK�dJdL�dMdN�}|dddJdO�|dddJdPdQ�|dddJdPdR�dJdO�dSdT�}|dddJdJdPdU�|dddJdPdJdV�|�
ttdW�|�
ttdX�|�
ttdY�dZd[�}|�|dgddg�Rddd\��d]ddd\�f�|�|dgd(�d�R�d6if�|�
ttd^�|�|did_d`da���dd_d`da�f�|�|ddbd`idcd_i��dd_d`da�f�t
|dd�t
|de�dftfdgd[�}|�|jdfti�dEtfdhd[�}|�|jdEti�dEtfdid[�}|�|jdEti�d�dEtfdkd[�}|�|jdEti�dEtfdld[�}|�|jdEti�dEtfdmd[�}|�|jdEti�d�dod[�}|�|jdndi�d�dpd[�}|�|jdndi�d�dqd[�}|�|jdddr��d�dsd[�}|�|jdddr��d�d�dvd[�}|�|jdddddw��d�ddxdy�	}	f	~d�dd[�}|�|jddddddd}d~d���d�ddxdy�d$dd*ddtdd�tduddzdd{dd|d}dfd~fd�d[�}|�|jdddtdddd}d~d��	�Gd�d��d��}Gd�d��d�|�}|�|jjd�di�|�|jjd�di�d�d����dftfd�d[��}|�|jdfti��d�d[��}�}d�d[��}�fd�d��d�d[��}d��d�gdd�d[��}�����d�d[��}�gdjjd�d[��}d��fd�d[�}d �fd�d[�	}dd���fd�d[�
}dftf�fd�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[�}dS)�NcSr�rarrrrr�f1r�z%GrammarTests.test_funcdef.<locals>.f1rcSr�rar�Zone_argumentrrr�f2r�z%GrammarTests.test_funcdef.<locals>.f2cSr�rar��twoZ	argumentsrrr�f3r�z%GrammarTests.test_funcdef.<locals>.f3r�r�cSr�rar)Zone_argrrr�a1r�z%GrammarTests.test_funcdef.<locals>.a1cSr�rar)r��argsrrr�a2r�z%GrammarTests.test_funcdef.<locals>.a2cWr�rar��restrrr�v0r�z%GrammarTests.test_funcdef.<locals>.v0cWr�rar�rr�rrr�v1r�z%GrammarTests.test_funcdef.<locals>.v1cWr�rar�rr�r�rrr�v2 r�z%GrammarTests.test_funcdef.<locals>.v2r'rr�r�rs���rrcSr�rar�rrrr�d016r�z&GrammarTests.test_funcdef.<locals>.d01�r'rcSr�rarr~rrr�d11>r�z&GrammarTests.test_funcdef.<locals>.d11r�cSr�rar�rr�r�rrr�d21Br�z&GrammarTests.test_funcdef.<locals>.d21�r'rr��rr��r�r�cSr�rarr~rrr�d02Ir�z&GrammarTests.test_funcdef.<locals>.d02r}�rr~cSr�rarr�rrr�d12Qr�z&GrammarTests.test_funcdef.<locals>.d12cSr�rar�rr�r��drrr�d22Ur�z&GrammarTests.test_funcdef.<locals>.d22cWr�rarr�rrr�d01vYr�z'GrammarTests.test_funcdef.<locals>.d01v)r'rr�r�cWr�rarr�rrr�d11v`r�z'GrammarTests.test_funcdef.<locals>.d11vcWr�rar�rr�r�r�rrr�d21vdr�z'GrammarTests.test_funcdef.<locals>.d21vcWr�rarr�rrr�d02vjr�z'GrammarTests.test_funcdef.<locals>.d02vr�cWr�rarr�rrr�d12vqr�z'GrammarTests.test_funcdef.<locals>.d12v�r�r�rscWr�rar)rr�r�r�r�rrr�d22vyr�z'GrammarTests.test_funcdef.<locals>.d22vr�r&rsfooz/Bytes should not work as keyword argument namescS�|Srar��keyrrr�pos0key1�r�z+GrammarTests.test_funcdef.<locals>.pos0key1�dr�)�k2cSs||||fSrar)�p1�p2�k1r�rrr�pos2key2��z+GrammarTests.test_funcdef.<locals>.pos2key2)r��)rr�)r�rc[s|||||fSrar)r�r�rr��kwargrrr�pos2key2dict��z/GrammarTests.test_funcdef.<locals>.pos2key2dict)r��tokwarg1�tokwarg2)rrr�zdef f(*): passzdef f(*,): passzdef f(*, **kwds): passc_s||fSrar)r��kwargsrrrr��sz$GrammarTests.test_funcdef.<locals>.f�rrR)r'r�r�zf(1, x=2, *(3,4), x=5)Z	scrambledZfried)�eggsrErErz
f(*g(1=2))zf(**g(1=2))�returncSr�rarr�rrrr��r�cSr�rarr�rrrr��r�cSr�rarr�rrrr��r�rMcSr�rarr�rrrr��r�cWr�rarr�rrrr��r�c[r�rarr�rrrr��r�rRcSr�rarr
rrrr��r�cSr�rarr
rrrr��r�cSr�rarr�rrrr��r�)r�r�cSr�rarr�rrrr��r�r��gcWr�rar)rr�r�r�r�r�r
rrrr��r�)r�r�r�r
�
��i�j�hr�k��c_r�rar�rr�r�r�r�r�rrrr
rrrrr��rx)r�r�r�r
rrrrr�c_r�rarrrrrr��rx)	r�r�r�r�r
rrrrc@seZdZddd�ZdS)z'GrammarTests.test_funcdef.<locals>.Spam�	_Spam__kwr'cSr�rar)rrrrrr��rxz)GrammarTests.test_funcdef.<locals>.Spam.fN)rr')rZr[r\r�rrrr�Spam�src@r�)z&GrammarTests.test_funcdef.<locals>.HamNr�rrrr�Ham�rrrcSr�rarr�rrr�null�r�z'GrammarTests.test_funcdef.<locals>.nullcSr�rarr�rrrr��rxFcSr�rarr�rrrr��rxcSr�rarr�rrrr��rxc��|�Srar�r�)rrr�<lambda>��z+GrammarTests.test_funcdef.<locals>.<lambda>cSr�rarr�rrrr��rx.cSr�rarr�rrrr��rxcSr�rarr�rrrr��rxcSr�rarr�rrrr��rxc��Srarr��closurerrr��r�crrarr�r rrr��r��rcrrarr"r rrr��r�crrarrr rrr��r�cSr�rarr�rrrr��r�cWr�rar�r�rrrr��r�c[r�rar�r�rrrr��r�cWr�rar�rr�rrrr��r�c[r�rar�rr�rrrr��r�cWr�rar�r�r�rrrr��r�cSr�rar�r�rrrr��r�c_r�rar�r�r�rrrr��r�cWr�rar�rr�r�rrrr��r�cSr�rarr~rrrr��r�c_r�rar�rr�r�rrrr��r�c_r�rar�r�r�r�rrrr��r�c[r�rar�r�r�rrrr��r�c_r�rar�rr�r�r�rrrr��r�c[r�rar�rr�r�rrrr��r�r�)rM)rRr�)r�r'r�r)r�rr�r')r�rs)r�r'r�rr�r�r
r�)r�r'r�rr�r�r
r�rr�rrrrrr)r�__code__�co_varnamesr(r)r*�BytesWarningrW�	TypeErrorr!rrrrrzr�ryr�r��__call__)rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�rrr�r)r!rr�test_funcdefs�





























�
��	
 � ��





�
�
���(�
���







zGrammarTests.test_funcdefcCsVdd�}|�|�d�dd�}dd�}|�|�gd��d'dd�fd	d�fd
d�}|�|�d�d(dd�}|�|dd�d
�|�|ddd�d�t|d�t|d�dd�dd�}|�|dd�d�|�|dddd�d�dd�}dd�}dd�}	dd�}
dd�}dd�}dd�}
dd�}d d�}d!d�}d"d�}d#d�}d$d�}d%d�}d&d�}dS))NcSru�Nrrrrrrrr�z+GrammarTests.test_lambdef.<locals>.<lambda>rcSsttSra)rr�rrrrrrcSsdd�dD�S)NcSsg|]}d|k�qSr�r��.0rrrr�
<listcomp>�z?GrammarTests.test_lambdef.<locals>.<lambda>.<locals>.<listcomp>)���r�rrrrrrrr)rr'rr'cSr�rar�r�rrrrr�cS�|�Srar)rRrrrr�cSr=rarr�rrrrr>rcS�|||Srar)rrRr�rrrrrrsr�r�zlambda x: x = 2zlambda (None,): None�r"cSr?rar)rrRrrrrr
r�r�
cSrur6rr�rrrrr�cWrur6rr#rrrrr�c[rur6rr$rrrrr�cWrur6rr%rrrrr�c[rur6rr&rrrrr�cWrur6rr'rrrrr�cSrur6rr(rrrrr�c_rur6rr)rrrrr�cWrur6rr*rrrrr�cSrur6rr~rrrrr�c_rur6rr+rrrrr�c_rur6rr,rrrrr�c[rur6rr-rrrrr�c_rur6rr.rrrrr�c[rur6rr/rrrr r�r�r��rr)r�l1�l2�l3�l4�l5�l6�l10Zl11Zl12Zl13Zl14Zl15Zl16Zl17Zl18Zl19Zl20Zl21Zl22Zl23Zl24rrr�test_lambdef�s<


zGrammarTests.test_lambdefcCsd}~dd�}|�dS)Nr'cSs
d}~dSrvrr�rrr�foo)r�z*GrammarTests.test_simple_stmt.<locals>.foor)rrrLrrr�test_simple_stmt&s
zGrammarTests.test_simple_stmtc	CsV		d}d}d}}}d\}}}d}\}}}\}}}}t|d�t|d�dS)Nr'r�)r'r)r�r�z	x + 1 = 1z
a + 1 = b + 2r)	rrrRr��abcrr�r��xyzrrr�test_expr_stmt1s

zGrammarTests.test_expr_stmtcCsd}gd�}|D]w}d�|�}|D]m}|�|�}|j|d��"|�t|��t|�Wd�n1s4wYWd�n1sCwY|�dd�}|j|d��"|�td��t|�Wd�n1sjwYWd�n1sywYqqdS)N)r�rV)z{} fooz{} {{1:foo}}zif 1: {} foozif 1: {} {{1:foo}}zif 1:
    {} foozif 1:
    {} {{1:foo}}zcall to '{}')�sourcerLz(foo.)zinvalid syntax)�formatr;ZassertRaisesRegexrrVr1)r�keywords�cases�keywordZ
custom_msg�caserQrrr�(test_former_statements_refer_to_builtins@s,


���
������z5GrammarTests.test_former_statements_refer_to_builtinscCs�gd�}|\}}}|||f}~~~~~d\}}}~~~d\}}}}	}
}}~~~~	~
~d\}}}}	}
}}~~~~	~
~td�}
|
dd�=tddd	�dS)
Nr�rOZabcdefg�abcdr'rz-del a, (b[0].c, (d.e, f.g[1:2])), [h.i.j], ()r:rV)rzr<)rrNrrRr�rOrr�r�r�r�r�r
rXrrr�
test_del_stmtWs 



zGrammarTests.test_del_stmtcCr�rarr,rrr�test_pass_stmtq�zGrammarTests.test_pass_stmtcCr�rarr,rrr�test_break_stmtxr[zGrammarTests.test_break_stmtcCsxd}|rd}qd}|sd}zWq	d}Y|r|dkr!|�|�d}|s/d}zWd}q#d}w|dkr:|�|�dSdS)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'rcs`d}|r|d7}z|r|dkr|d8}Wn
|d8}Wq�|dks'|dkr.��d�dSdS)Nrr'z1continue then break in try/except in loop broken!r^)Zextra_burning_oil�countZ	big_hippor,rr�
test_inner�s�z9GrammarTests.test_break_continue_loop.<locals>.test_inner)r'rr)rrbrr,r�test_break_continue_loop�s

z%GrammarTests.test_break_continue_loopcCsFdd�}dd�}dd�}|�|�}|�}|�|dd�t|d	�dS)
NcSr�rarrrrr�g1�r�z$GrammarTests.test_return.<locals>.g1cSrurvrrrrr�g2�r�z$GrammarTests.test_return.<locals>.g2cSsddg}dg|�RS)Nrr�r'rr<rrr�g3�sz$GrammarTests.test_return.<locals>.g3r�z unparenthesized star expr returnzclass foo:return 1rC)rrdrerfrrRrrr�test_return�szGrammarTests.test_returncCs4d}|dkr|d7}zWnY|�|d�d}|dkr(|d7}zWnY|�|d�d}|dkrC|d7}zddWnY|�|d�dD]}|�|d�zWnY|�|d�dD]}|�|d�zWnY|�|d�dD]}|�|d�zddWnY|�|d�dS�Nrrr'�rr'r
�rrarrr�test_break_in_finally�sN




z"GrammarTests.test_break_in_finallycCsd}|dkr|d7}zWqYq|�|d�d}|dkr*|d7}zWqYq|�|d�d}|dkrF|d7}zddWq2Yq2|�|d�dD]	}zWqNYqN|�|d�dD]	}zWq`Yq`|�|d�dD]
}zddWqrYqr|�|d�dSrhr
rjrrr�test_continue_in_finally�sH

z%GrammarTests.test_continue_in_finallycCsFdd�}|�|�d�dd�}|�|�d�dd�}|�|�d	�dS)
NcS�zWdSYdSrvrrrrrrd(�z/GrammarTests.test_return_in_finally.<locals>.g1r'cSrm)Nr�rrrrrre/rnz/GrammarTests.test_return_in_finally.<locals>.g2r�cSszddWdSYdS)Nr'rr�rrrrrrf6s
z/GrammarTests.test_return_in_finally.<locals>.g3r�r
)rrdrerfrrr�test_return_in_finally'sz#GrammarTests.test_return_in_finallycCsTdd�}|�|d�d�|�|d�d�dd�}|�|d�d�|�|d�d�dS)	NcSsPdD] }d}|dkr"|d7}z||W|rnS|r!Ynwqd||fS)Nrirr@r�endr�rraZcount2rrrrd?s
��
z;GrammarTests.test_break_in_finally_after_return.<locals>.g1FrT)rpr'rc	SsLdD]}dD]}z||W|rnS|rYnwqd||fS)Nri)rr@rprrqrrrreMs��
z;GrammarTests.test_break_in_finally_after_return.<locals>.g2r
�rrdrerrr�"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}|dkr|d7}z|W|rqS|rYqwd|fS)Nrr�r'rpr�rrarrrrd[s�z>GrammarTests.test_continue_in_finally_after_return.<locals>.g1Fr'T)rpr�cSs4dD]}z	|W|rqS|rYqwd|fS)Nrirprrtrrrrehs
�z>GrammarTests.test_continue_in_finally_after_return.<locals>.g2r)rpr'r
rrrrr�%test_continue_in_finally_after_returnYs
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)Ncs��dVdSrvrrrrrr
u��
z"GrammarTests.test_yield.<locals>.gcss�dEdHdS�Nrrrrrrr
v��cs��dV}dSrvrr�rrrr
xrwcss�dEdH}dSrxrr�rrrr
yrycsrv�N)r'r'rrrrrr
{rwcsrzr{rr�rrrr
|rwzdef g(): yield from (), 1zdef g(): x = yield from (), 1css�ddVfdSrvrrrrrr
�rycss�ddEdHfdS�Nr'rrrrrrr
���zdef g(): 1, yield 1zdef g(): 1, yield from ()css�tdV�dSrvrrrrrr
�rycss�tdVd�dSrvrrrrrr
�s�css�tdEdH�dSrxrrrrrr
�r}css�tdEdHd�dS)Nrr'rrrrrr
���css�d}dddg|�RVdS)N�r�rsr�r'rr�rr�rrrr
���)r'rr�r�rsr�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)rrrz�rr
rrr�
test_yieldss6











zGrammarTests.test_yieldcCs~dd�}dd�}|j}|dd�|dd�|dd�|dd	�|d
d�|dd�|d
d�|dd�|dd�|dd�dS)Ncss�dd�dVfD�dS)NcS�g|]}|�qSrrr7rrrr9���HGrammarTests.test_yield_in_comprehensions.<locals>.g.<locals>.<listcomp>r'rrrrrr
���z4GrammarTests.test_yield_in_comprehensions.<locals>.gcss�dd�dEdHfD�dS)NcSr�rrr7rrrr9�r�r�rrrrrrr
�r�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
r6rrr�test_yield_in_comprehensions�sB����������z)GrammarTests.test_yield_in_comprehensionscCs6ztd��ty
Ynwzt�tyYdSw)Nzjust testing)�RuntimeError�KeyboardInterruptr,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�)rrr�r�r�rrr�test_import�szGrammarTests.test_importcCr�rarr,rrr�test_global�r�zGrammarTests.test_globalcsd�d���fdd�}dS)Nrcr�rarrr
rrr��r�z%GrammarTests.test_nonlocal.<locals>.fr)rr�rr
r�
test_nonlocal�szGrammarTests.test_nonlocalc
CslzWnty}z|�d�WYd}~nd}~wwzWdSty5}z|�d�WYd}~dSd}~ww)Nz6'assert True' should not have raised an AssertionErrorz;'assert True, msg' should not have raised an AssertionError)�AssertionErrorr!�rr�rrr�test_assert�s����zGrammarTests.test_assertFz Won't work if __debug__ is Falsec
Cs�zWnty}z|�|jdd�WYd}~n
d}~ww|�d�zWntyA}z|�t|j�d�WYd}~dSd}~ww|�d�dS)Nrr_z%AssertionError not raised by assert 0z+AssertionError not raised by 'assert False')r�rr�r!rOr�rrr�test_assert_failures�s��
 ��z!GrammarTests.test_assert_failurescCsn|�dd�|�dd�|�dd�|jtd��tddd�td	dd�Wd�dS1s0wYdS)
N�assert(x, "msg")zassertion is always true�assert(False, "msg")�assert(False,))�categoryzassert x, "msg"r:rVzassert False, "msg")rrprHr<r,rrr�test_assert_syntax_warnings�s���"�z(GrammarTests.test_assert_syntax_warningsc	Cst���t�dt�ztddd�Wnty!|�d�Ynw|�t��tddd�Wd�n1s8wY|�t��tddd�Wd�n1sSwY|�t��tddd�Wd�n1snwYWd�dSWd�dS1s�wYdS)	Nr>zassert x, "msg" r:rVz4SyntaxError incorrectly raised for 'assert x, "msg"'r�r�r�)r(r)r*rHr<rr!rr,rrr�,test_assert_warning_promotes_to_syntax_errors&
�����
"�z9GrammarTests.test_assert_warning_promotes_to_syntax_errorcCs									dSrarr,rrr�test_ifszGrammarTests.test_ifcCs 			d}	d}|�|d�dS)Nrr'rr
rrrr�
test_while*szGrammarTests.test_whilecCs�dD]}qdD]\}}}q	Gdd�d�}d}|d�D]}||}q|dkr+|�d�g}d	D]\}|�|�q/|�|gd��dS)
Nr�rc@r^)z&GrammarTests.test_for.<locals>.SquarescSs||_g|_dSra)�max�sofar)rr�rrrrd?s
z/GrammarTests.test_for.<locals>.Squares.__init__cSs
t|j�Sra)rOr�r,rrr�__len__Bs
z.GrammarTests.test_for.<locals>.Squares.__len__cSsZd|kr|jkst�t�t|j�}||kr(|j�||�|d}||ks|j|S)Nrr')r��
IndexErrorrOr��append)rr�nrrrrmCs
�
z2GrammarTests.test_for.<locals>.Squares.__getitem__N)rZr[r\rdr�rmrrrr�Squares>sr�rrizfor over growing sequence)r�r�r�)r!r�r)rrrrr�r�r�resultrrr�test_for9s


zGrammarTests.test_forc
CszddWn	tyYnw	zddWnty Ynty1}zWYd}~n
d}~wYn	zddWntttfyIYnwzddWntttfye}zWYd}~nd}~wwzWnw|�t��tddd�tddd�Wd�dS1s�wYdS)Nr'rz/try:
    pass
except Exception as a.b:
    pass�?rVz0try:
    pass
except Exception as a[b]:
    pass)r��EOFErrorr3rrr<)rr_rrr�test_tryTs0��
 �"�zGrammarTests.test_trycCs							dSrarr,rrr�
test_suitemszGrammarTests.test_suitecCs						dSrarr,rrr�	test_test|szGrammarTests.test_testcCs�	ddk}ddkr	ddkr
ddkrddkrddkrddkr||ur!||ur%ddvr)ddvr-ddkr_dkr_dkr_dkr_dkr_dkr_dvr_|vr_|ur_|urendS	dSdSr|rrrrr�test_comparison�stzGrammarTests.test_comparisoncs�d�fdd�	}|d�|d�|d�|d�|dd	�t���'t�d
t�tddd
�tddd
�tddd
�tddd
�Wd�dS1sJwYdS)NrCcs��||�dSrar)r=r_r,rrr6��z6GrammarTests.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 literalr>z	x is Noner:rVz
x is Falsez	x is Truezx is ...)rC�r(r)r*rHr<r5rr,r�test_comparison_is_literal�s

"�z'GrammarTests.test_comparison_is_literalcsn��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���3t�dDt�tdEdFdG�tdHdFdG�tdIdFdG�tdJdFdG�tdKdFdG�tdLdFdG�Wd�dS1�s0wYdS)MNcs��|��dSrar)r=�r_rrrr6�r�z2GrammarTests.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] [...]]r>z[(lambda x, y: x) (3, 4)]r:rVz[[1, 2] [i]]z[[1, 2] [0]]z[[1, 2] [True]]z[[1, 2] [1:2]]z[{(1, 2): 3} [i, j]]r�r5rr�r�test_warn_missed_comma�s�
$�z#GrammarTests.test_warn_missed_commacCsd}d}d}dS)Nr'rrrrrr�test_binary_mask_ops��z!GrammarTests.test_binary_mask_opscCsd}d}d}dS)Nrrr'rrrrr�test_shift_opsr�zGrammarTests.test_shift_opscCsd}d}d}d}dS)Nr'rr;rrrrr�test_additive_ops�zGrammarTests.test_additive_opscCsd}d}d}d}dS)Nr'��?rgrrrrr�test_multiplicative_opsr�z$GrammarTests.test_multiplicative_opscCsd}d}d}d}d}dS)Nr'r;���r�rrrrr�test_unary_opss
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;rs���������r'rr�r�r}r�r�cSst|�j|fSra)rrZr�rrrr3rz-GrammarTests.test_selectors.<locals>.<lambda>r�z[1, (1,), (1, 2), (1, 2, 3)])rr�r��modulesrz�sortrrW)	rrr�r�rrr"r��Lrrr�test_selectorss,
zGrammarTests.test_selectorscCs�d}d}dddf}g}dg}dg}dddg}g}i}ddi}ddi}ddi}ddd�}ddd�}dddddd	d
�}dh}ddh}hd�}hd�}|}d
}d}dS)Nr'rr�rwr�)rwr�r�rsr�)rwr��threeZfourZfiveZsix>r�rwr�>rr�r�rr�rrrrr�
test_atoms6s,



zGrammarTests.test_atomscsGdd�d�}Gdd�d�}Gdd�d|�}Gdd�d|�}Gd	d
�d
|||�}Gdd�d�}d
d���Gdd�d��}�Gdd�d��}�}	Gdd�d��}
�fdd�Gdd�d��}d�dgdGdd�d��}�����Gdd�d��}
�gd jjGd!d"�d"��}dS)#Nc@r�)z%GrammarTests.test_classdef.<locals>.BNr�rrrrr�[rr�c@r�)z&GrammarTests.test_classdef.<locals>.B2Nr�rrrr�B2\rr�c@r�)z&GrammarTests.test_classdef.<locals>.C1Nr�rrrr�C1]rr�c@r�)z&GrammarTests.test_classdef.<locals>.C2Nr�rrrr�C2^rr�c@r�)z%GrammarTests.test_classdef.<locals>.DNr�rrrrr�_rr�c@r^)z%GrammarTests.test_classdef.<locals>.CcSr�rarr,rrr�meth1ar�z+GrammarTests.test_classdef.<locals>.C.meth1cSr�rar)r�argrrr�meth2br�z+GrammarTests.test_classdef.<locals>.C.meth2cSr�rar)rr�r�rrr�meth3cr�z+GrammarTests.test_classdef.<locals>.C.meth3N)rZr[r\r�r�r�rrrrr�`sr�cSr�rarr�rrr�class_decoratorhr�z3GrammarTests.test_classdef.<locals>.class_decoratorc@r�)z%GrammarTests.test_classdef.<locals>.GNr�rrrr�Gir�r�Fc@r�)z%GrammarTests.test_classdef.<locals>.HNr�rrrr�Hmr�r�c@r�)z%GrammarTests.test_classdef.<locals>.INr�rrrr�Ior�r�crrar)r��r�rrrqrz,GrammarTests.test_classdef.<locals>.<lambda>c@r�)z%GrammarTests.test_classdef.<locals>.JNr�rrrr�Jqr�r�.r'c@r�)z%GrammarTests.test_classdef.<locals>.KNr�rrrr�Ksr�r�c@r�)z%GrammarTests.test_classdef.<locals>.LNr�rrrrr�ur�r�rc@r�)z%GrammarTests.test_classdef.<locals>.MNr�rrrrr�wr�r�)r4)rr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�
test_classdefYs*

zGrammarTests.test_classdefcCs*gd�}|�dd�|D�dddd��dS)Nr�cSsi|]}||d�qSr�r�r8rrrr�
<dictcomp>sz/GrammarTests.test_dictcomps.<locals>.<dictcomp>rr�r�r
)r�numsrrr�test_dictcompszs"zGrammarTests.test_dictcompsc	sZgd�}gd��gd�}��dd�|D�gd����dd�|D�gd����d	d�|D�gd
�����fdd�|D�gd�����fd
d�|D�gd����dd�td�D�dgddggd�gd�gd�g�dd�}��||�gd���fdd�}|�t�d�t�d�gd�}gd��gd����fdd�|D�}��|gd ��dS)!Nr�)�Apple�Banana�Coconut)z  Applez Banana zCoco  nut  cSsg|]}|���qSr)�strip)r8r"rrrr9�r:z/GrammarTests.test_listcomps.<locals>.<listcomp>)r�r�z	Coco  nutcSsg|]}d|�qSr�rr7rrrr9�r:)r�r�rr�cSsg|]}|dkr|�qSr�rr7rrrr9��r�csg|]}�D]}||f�qqSrr�r8rr"��strsrrr9��))r'r��r'r��r'r�)rr��rr��rr�)r�r��r�r��r�r�)r�r��r�r��r�r�)rsr��rsr��rsr�cs(g|]}dd��D�D]}||f�qqS)cSsg|]}d|vr|�qS)r�r)r8r�rrrr9�r�z:GrammarTests.test_listcomps.<locals>.<listcomp>.<listcomp>rr�r�rrr9�s()
r�r�r�r�r�r�r�r�r�r�cSsg|]}dd�|��qS)cs�fdd�t�d�D�S)Ncsg|]}�|�qSrrr�r�rrr9�r:zLGrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>.<locals>.<listcomp>r'��ranger�rr�rr�sz8GrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>r)r8rrrrr9�r�rsr')r'rr�)r'r�r�)r'r���@�cSsdd�|D�S)NcSs,g|]}|dkrd|kodkn�qS)rrr�rr7rrrr9�s,zEGrammarTests.test_listcomps.<locals>.test_in_func.<locals>.<listcomp>r)�lrrr�test_in_func�r�z1GrammarTests.test_listcomps.<locals>.test_in_func)FFFcs,��dd�dD�ddgddgdd	gg�dS)
NcSs"g|]
}dd�||dfD��qS)cSr�rr�r8rRrrrr9�r�zUGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>.<listcomp>r'rr7rrrr9��"zJGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>)r'r�rsr'rr�r�rsr�r
rr,rr�test_nested_front�s�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@)rr@)r�r�csDg|]\}}�D]\}}�D]\}}||kr||kr||f�qqqSrr)r8ZsnoZsnameZpnoZpnameZsp_snoZsp_pno)�parts�suppartrrr9�s���
))r�r�)r�r�)r�r�)r�r�)rr�r)rr�Zspcsr�r�Z	suppliersrr)r�rr�r�r�test_listcomps�s8���

�zGrammarTests.test_listcompscs�dd�td�D�}|�t|�dd�td�D��zt|�|�d�Wn	ty,Ynwd�z�fdd��D�}t|�|�d	�Wn	tyLYnw|�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)cSr�rrr7rrrr9�r�z7GrammarTests.test_genexps.<locals>.<genexpr>.<listcomp>rNr�r7rrr�	<genexpr>��� z,GrammarTests.test_genexps.<locals>.<genexpr>r'cSr�rrr7rrrr9�r�z-GrammarTests.test_genexps.<locals>.<listcomp>rz&should produce StopIteration exceptionc3s�|]}�VqdSrar)r8r�r�rrr�r}zshould produce TypeErrorcs�"�|]}dD]}||fVqqdS)rXNr�r8rrRrrrr�rrXcS�g|]}dD]}||f�qqS)rXrrrrrr9�r�csr)�xyNrrrrrr�rZabcSr)rrrrrrr9�r�cSr�rrr7rrrr9�r�cs��|]}|VqdSrarr7rrrr�r}csrrarr�rrrr�r}cSr�rrr7rrrr9�r�css�|]}|dVqdS�rNrr7rrrr�r�cSsg|]}|d�qSr�rr7rrrr9�r:css �|]}|dr||VqdSrrr7rrrr�s�cSsg|]
}|dr||�qSr�rr7rrrr9��csrrarr7rrrr�r}csrrarr�rrrr�r}cSr�rrr7rrrr9�r�csrrarr7rrrr�r}csrrarr�rrrr�r}csrrar�r8r�rrrr�r}cSr�rrr7rrrr9�r�csrrarr7rrrr�r}cSr�rrr�rrrr9�r�csrrarr	rrrr�r}cSr�rrr7rrrr9�r�cs��|]}|VqdS�TNrr7rrrr�r}csrrarr�rrrr�r}csr
rrr	rrrr�r}cSr�rrr7rrrr9�r�csr
rrr7rrrr�r}css�|]}qdS)FNrr�rrrr�s�csr
rrr	rrrr�r}rzfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r�r�nextr!�
StopIterationr3rz�sumr)rr
r�rr�r�test_genexps�s<��$$"00:DDD2
zGrammarTests.test_genexpscs�d�dd�t��D�}d�|�tt|��d�d�d���fdd�t��D�}d�d�|�dd	�td�D�t|��|�d
d	�td�D�gd��|�tdd�td�D��gd��|�d
d	�dD�gd��|�tdd�dD��gd��dS)Nrcsrrarr�rrrr�r}z;GrammarTests.test_comprehension_specials.<locals>.<genexpr>rsFc3s*�|]}�rt��D]}||fVq
qdSrar��r8rr��trrrr�s�(TcSs"g|]
}td�D]}||f�qqS�rsr�rrrrr9�r�z<GrammarTests.test_comprehension_specials.<locals>.<listcomp>cSs g|]}|dr|dr|�qSr�rr7rrrr9�s )r'rsr�css$�|]
}|dr|dr|VqdS)rr�Nrr7rrrr�s�"cSsg|]\}|�qSrrr7rrrr9�s))r�r)r�rcss�|]\}|VqdSrarr7rrrr�r~))r�)r�)r)r�r�r)r�rrOrzr�rrr�test_comprehension_specials�s ""z(GrammarTests.test_comprehension_specialsc
Cs�Gdd�dt�}|��Wd�n1swY|��}Wd�n1s)wY|��
\}}Wd�n1s>wY|��|��Wd�n1sUwYWd�n1sdwY|��}|��}Wd�n1s{wYWd�n1s�wY|��}|��Wd�n1s�wYWd�n1s�wY|��Wd�n1s�wY|��}Wd�n1s�wY|��\}}|��}Wd�n1s�wYWd�n1s�wY|��|��Wd�n	1�swYWd�n	1�s&wY|��}|��}Wd�n	1�s>wYWd�n	1�sNwY|��}|��Wd�n	1�sfwYWd�n	1�svwY|��0}|��}|��}Wd�n	1�s�wYWd�n	1�s�wYWd�n	1�s�wY|��9}|��}|��Wd�n	1�s�wYWd�n1�s�wYWd�dSWd�dS1�s�wYdS)Nc@�eZdZdd�Zdd�ZdS)z1GrammarTests.test_with_statement.<locals>.managercSru�Nr}rr,rrr�	__enter__�rxz;GrammarTests.test_with_statement.<locals>.manager.__enter__cWr�rar)rr�rrr�__exit__�rxz:GrammarTests.test_with_statement.<locals>.manager.__exit__N)rZr[r\rrrrrr�manager��r)�object)rrrrRr�rrr�test_with_statement�s�����������������������������������������Tz GrammarTests.test_with_statementcCsdd�}|�dd�dd�dd�fD�dg�|�d	d�d
d�dd�fD�dg�|�d
d
�|�d
d
�|�dd�|�dd�|�dd�|�dd�|�dd�|�d
d
�|�dd�|�dd�|�dd�|�d
d
�|�dd�|�dd�|�dd�dS)NcSs	t|�|Srar�)r_Zretrrr�
_checkeval<sz2GrammarTests.test_if_else_expr.<locals>._checkevalcSsg|]}|�r|��qSrrr7rrrr9Cr�z2GrammarTests.test_if_else_expr.<locals>.<listcomp>cSru)NTrrrrrrCr�z0GrammarTests.test_if_else_expr.<locals>.<lambda>cSru�NFrrrrrrCr�TcSsg|]
}|d�r|d��qSrFrr7rrrr9DrcS�|rdSdS)NFTrr�rrrrDrcSr)NTFrr�rrrrDrr'rszcheck 1rzcheck 2r�zcheck 3rr�zcheck 4zcheck 5zcheck 6Fr�rr�g@r
)rrrrr�test_if_else_expr:s$$$zGrammarTests.test_if_else_exprcCsx|�dd�|�dd�|�dd�d}d}|�d||uu�|�d|u|u�|�d|uo6|u�dS�dS)Nr�rr�F)rrZassertFalserQrrr�test_paren_evaluationUs(z"GrammarTests.test_paren_evaluationcCs>Gdd�d�}|�}|�||d�|d}|�|jd�dS)Nc@r)z'GrammarTests.test_matrix_mul.<locals>.McSru)Nr�r�rr�rrr�
__matmul__crxz2GrammarTests.test_matrix_mul.<locals>.M.__matmul__cSs
||_|Sra)�otherr"rrr�__imatmul__esz3GrammarTests.test_matrix_mul.<locals>.M.__imatmul__N)rZr[r\r#r%rrrrr�brr�r�rt)rr$)rr��mrrr�test_matrix_mul_s
zGrammarTests.test_matrix_mulcCsxdd�}|�|jd�|�t|jjtj@��dd�}|dd��}|�|j�|�|jd�|�t|jjtj@��dS)	Nc�s�dd�}	t�IdHdS)NcSr�rarrrrrrorxz8GrammarTests.test_async_await.<locals>.test.<locals>.sum)Zsomeobj)rrrrr=ns�z+GrammarTests.test_async_await.<locals>.testr=cSst|dd�|S)N�_markedT)�setattr)�funcrrr�	decoratorwsz0GrammarTests.test_async_await.<locals>.decoratorc���dS)N�rrrrr�test2{s�z,GrammarTests.test_async_await.<locals>.test2r.)	rrZr�boolr0�co_flags�inspectZCO_COROUTINEr()rr=r+r.rrr�test_async_awaitms
zGrammarTests.test_async_awaitcshGdd�dt��Gdd�d����fdd�}|����|��d�Wd�dS1s-wYdS)Nc@r�)z)GrammarTests.test_async_for.<locals>.DoneNr�rrrr�Done�rr3c@r)z*GrammarTests.test_async_for.<locals>.AItercSr�rarr,rrr�	__aiter__�rxz4GrammarTests.test_async_for.<locals>.AIter.__aiter__c�s�t�ra)�StopAsyncIterationr,rrr�	__anext__���z4GrammarTests.test_async_for.<locals>.AIter.__anext__N)rZr[r\r4r6rrrr�AIter�rr8c�sN���2z3dHW}q6��2z3dHW\}}q6��2z3dHW}q6	��rarr�r8r3rrrL�s����z(GrammarTests.test_async_for.<locals>.foo�r�r�send�rrLrr9r�test_async_for�s"�zGrammarTests.test_async_forcshGdd�dt��Gdd�d����fdd�}|����|��d�Wd�dS1s-wYdS)Nc@r�)z*GrammarTests.test_async_with.<locals>.DoneNr�rrrrr3�rr3c@r)z-GrammarTests.test_async_with.<locals>.managerc�r,rrr,rrr�
__aenter__�r7z8GrammarTests.test_async_with.<locals>.manager.__aenter__c�r,rr)r�excrrr�	__aexit__�r7z7GrammarTests.test_async_with.<locals>.manager.__aexit__N)rZr[r\r>r@rrrrr�rrc
�s���4IdH�Wd�IdHn1IdHswY��4IdH�}Wd�IdHn1IdHs6wY��4IdH�
\}}Wd�IdHn1IdHsUwY��4IdH�(��4IdH�Wd�IdHn1IdHszwYWd�IdHn1IdHs�wY��4IdH�(}��4IdH�}Wd�IdHn1IdHs�wYWd�IdHn1IdHs�wY��4IdH�)}��4IdH�Wd�IdHn1IdHs�wYWd�IdH��1IdH�swY��rarr
�r3rrrrL�s,�(�(�(� R� R� :��z)GrammarTests.test_async_with.<locals>.foor:r<rrAr�test_async_with�s"�zGrammarTests.test_async_withN)LrZr[r\r]r�test.support.warnings_helperrrprqr{r|r�r�r�r�r�r�r�r�r�r5rKrMrPrWrYrZr\r`rcrgrkrlrorsrur�r�r�r�r�r�r��unittestZ
skipUnlessr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr r!r'r2r=rBrrrrro8s�.		
y'45'



R#!?#D
ro�__main__)r]rrrCrr1rDrr(Ztest.ann_moduler�r��collectionsrr=r	r0r2ZTestCaserryr�r_rorZ�mainrrrr�<module>sH7D	
�