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.10/test/__pycache__/test_grammar.cpython-310.opt-2.pyc
o

�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�./usr/local/lib/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)rr6�numrr,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�str�	exception)rZsamplesr"�cmrrr�test_eof_error$s��zTokenTests.test_eof_errorN)�__name__�
__module__�__qualname__�test.supportrrr#r$r%r-r4r7rJrTrVr[rrrrrhs
$
(rZvar_annot_globalc@�$eZdZdd�Zdd�Zdd�ZdS)�CNScC�
i|_dS�N��_dctr,rrr�__init__0�
zCNS.__init__cCs||j|��<dSrc)re�lower�r�item�valuerrr�__setitem__2szCNS.__setitem__cC�
|j|Srcrd�rrjrrr�__getitem__4rgzCNS.__getitem__N�r\r]r^rfrlrorrrrra/srac@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_lstryrrr�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�dSrcrrrrr�f_OKy�z9GrammarTests.test_var_annot_basic_semantics.<locals>.f_OKcSst|�dSrc��print�rrrr�fbad|rtz9GrammarTests.test_var_annot_basic_semantics.<locals>.fbadcSstt�dSrc)r�Zno_such_globalrrrr�f2bad�rtz: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
||_dSrcr�rrrrrf�rgz?GrammarTests.test_var_annot_basic_semantics.<locals>.C.__init__N)	r\r]r^r{�__annotations__r"rX�zrfrrrr�C�s

r�)r�r"c@seZdZUde_edS)z9GrammarTests.test_var_annot_basic_semantics.<locals>.CBadrN)r\r]r^Zno_such_name_definedr�r{rrrr�CBad�s
r�c@s eZdZUeed<ge_edS)z:GrammarTests.test_var_annot_basic_semantics.<locals>.Cbad2rN)r\r]r^r{r�rrSr|rrrr�Cbad2�s
r�)
r�ZeroDivisionErrorZno_nameZdoes_not_existr3rr��UnboundLocalError�	ExceptionZassertIsrr{rX)	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�r\r]r^r{r�rrrr�A��
r�c@�eZdZdS)z4GrammarTests.test_annotations_inheritance.<locals>.BN�r\r]r^rrrr�B��r�c@r�)z4GrammarTests.test_annotations_inheritance.<locals>.Cr�N)r\r]r^rXr�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�r{rX)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�)ra)�metacls�name�bases�kwdsrrr�__prepare__��
zJGrammarTests.test_var_annot_metaclass_semantics.<locals>.CMeta.__prepare__N)r\r]r^�classmethodr�rrrr�CMeta�sr�c@seZdZUded<dS)z;GrammarTests.test_var_annot_metaclass_semantics.<locals>.CC�ANNOTZXXN)r\r]r^r�rrrr�CC�r�r�)�	metaclass�xxr�)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'rrSr��u�{)Z123�o)rr=r��
ann_moduler{rX�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_module3ru)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)rWrr{r�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>.CNS2cSrbrcrdr,rrrrf�rgz>GrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__init__c�||j|<|�|<dSrcrdri��	nonloc_nsrrrl��
zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__setitem__cSrmrcrdrnrrrro�rgzAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__getitem__Nrprr�rr�CNS2�sr�z
x: int = 1)rarWrr{rXrr�)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�rdr,)�cnsrrrf��z:GrammarTests.test_var_annot_refleak.<locals>.CNS2.__init__cr�rcrdrir�rrrl�r�z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__setitem__cSrmrcrdrnrrrro�rgz=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__getitem__Nrpr�r�r�rrr��sr�zX: strr)rarWrrX)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, 2rrzdef f():
    x: int = yieldr�r'�r��ru)r�r��cr�zx: Tuple[int, ...] = a,*b,c�r'rr�r�ru)rWrr|r�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�rcrrrrr�f1r�z%GrammarTests.test_funcdef.<locals>.f1rcSr�rcr�Zone_argumentrrr�f2r�z%GrammarTests.test_funcdef.<locals>.f2cSr�rcr��twoZ	argumentsrrr�f3r�z%GrammarTests.test_funcdef.<locals>.f3r�r�cSr�rcr)Zone_argrrr�a1r�z%GrammarTests.test_funcdef.<locals>.a1cSr�rcr)r��argsrrr�a2r�z%GrammarTests.test_funcdef.<locals>.a2cWr�rcr��restrrr�v0r�z%GrammarTests.test_funcdef.<locals>.v0cWr�rcr�r�r�rrr�v1r�z%GrammarTests.test_funcdef.<locals>.v1cWr�rcr�r�r�r�rrr�v2 r�z%GrammarTests.test_funcdef.<locals>.v2r'rr�r�ru���rrcSr�rcr�r�rrr�d016r�z&GrammarTests.test_funcdef.<locals>.d01�r'r�cSr�rcrr�rrr�d11>r�z&GrammarTests.test_funcdef.<locals>.d11r�cSr�rcr�r�r�r�rrr�d21Br�z&GrammarTests.test_funcdef.<locals>.d21�r'rr��rr��r�r�cSr�rcrr�rrr�d02Ir�z&GrammarTests.test_funcdef.<locals>.d02r�rr�cSr�rcrr�rrr�d12Qr�z&GrammarTests.test_funcdef.<locals>.d12cSr�rcr�r�r�r��drrr�d22Ur�z&GrammarTests.test_funcdef.<locals>.d22cWr�rcrr�rrr�d01vYr�z'GrammarTests.test_funcdef.<locals>.d01v)r'rr�r�cWr�rcrr�rrr�d11v`r�z'GrammarTests.test_funcdef.<locals>.d11vcWr�rcr�r�r�r�r�rrr�d21vdr�z'GrammarTests.test_funcdef.<locals>.d21vcWr�rcrr�rrr�d02vjr�z'GrammarTests.test_funcdef.<locals>.d02vr�cWr�rcrr�rrr�d12vqr�z'GrammarTests.test_funcdef.<locals>.d12v�r�r�rucWr�rcr)r�r�r�r�r�rrr�d22vyr�z'GrammarTests.test_funcdef.<locals>.d22vr�r&rsfooz/Bytes should not work as keyword argument namescS�|Srcr��keyrrr�pos0key1�r�z+GrammarTests.test_funcdef.<locals>.pos0key1�dr�)�k2cSs||||fSrcr)�p1�p2�k1rrrr�pos2key2��z+GrammarTests.test_funcdef.<locals>.pos2key2)r��)rr)rrc[s|||||fSrcr)rrrr�kwargrrr�pos2key2dict��z/GrammarTests.test_funcdef.<locals>.pos2key2dict)r�tokwarg1�tokwarg2)r
rrzdef f(*): passzdef f(*,): passzdef f(*, **kwds): passc_s||fSrcr)r��kwargsrrrr��sz$GrammarTests.test_funcdef.<locals>.f�rrS)r'r�r�zf(1, x=2, *(3,4), x=5)Z	scrambledZfried)�eggsrErErz
f(*g(1=2))zf(**g(1=2))�returncSr�rcrr�rrrr��r�cSr�rcrr�rrrr��r�cSr�rcrr�rrrr��r�rNcSr�rcrr�rrrr��r�cWr�rcrr�rrrr��r�c[r�rcrr�rrrr��r�rScSr�rcrr
rrrr��r�cSr�rcrr
rrrr��r�cSr�rcrr�rrrr��r�)r�r�cSr�rcrr�rrrr��r�r��gcWr�rcr)r�r�r�r�r�r�rrrrr��r�)r�r�r�r�
��i�j�hr�k��c_r�rcr�r�r�r�r�r�r�rrrrrrrrr��rz)r�r�r�rrrrrr�c_r�rcrrrrrr��rz)	r�r�r�r�rrrrrc@seZdZddd�ZdS)z'GrammarTests.test_funcdef.<locals>.Spam�	_Spam__kwr'cSr�rcr)rrrrrr��rzz)GrammarTests.test_funcdef.<locals>.Spam.fN)rr')r\r]r^r�rrrr�Spam�src@r�)z&GrammarTests.test_funcdef.<locals>.HamNr�rrrr�Ham�rrrcSr�rcrr�rrr�null�r�z'GrammarTests.test_funcdef.<locals>.nullcSr�rcrr�rrrr��rzFcSr�rcrr�rrrr��rzcSr�rcrr�rrrr��rzc��|�Srcr�r�)rrr�<lambda>��z+GrammarTests.test_funcdef.<locals>.<lambda>cSr�rcrr�rrrr��rz.cSr�rcrr�rrrr��rzcSr�rcrr�rrrr��rzcSr�rcrr�rrrr��rzc��Srcrr��closurerrr��r�cr"rcrr�r#rrr��r��rcr"rcrr%r#rrr��r�cr"rcrrr#rrr��r�cSr�rcrr�rrrr��r�cWr�rcr�r�rrrr��r�c[r�rcr�r�rrrr��r�cWr�rcr�r�r�rrrr��r�c[r�rcr�r�r�rrrr��r�cWr�rcr�r�r�rrrr��r�cSr�rcr�r�rrrr��r�c_r�rcr�r�r�rrrr��r�cWr�rcr�r�r�r�rrrr��r�cSr�rcrr�rrrr��r�c_r�rcr�r�r�r�rrrr��r�c_r�rcr�r�r�r�rrrr��r�c[r�rcr�r�r�rrrr��r�c_r�rcr�r�r�r�r�rrrr��r�c[r�rcr�r�r�r�rrrr��r�r�)rN)rSr�)r�r'r�r)r�rr�r')r�ru)r�r'r�rr�r�rr�)r�r'r�rr�r�rr�rr�rrrrrr)r�__code__�co_varnamesr(r)r*�BytesWarningrX�	TypeErrorr!rrrrr|r�r{r�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))NcSrw�Nrrrrrrr r�z+GrammarTests.test_lambdef.<locals>.<lambda>rcSsttSrc)r�r�rrrrr r!cSsdd�dD�S)NcSsg|]}d|k�qSr�r��.0rrrr�
<listcomp>�z?GrammarTests.test_lambdef.<locals>.<lambda>.<locals>.<listcomp>)���r�rrrrrrr r	)rr'rr'cSr�rcr�r�rrrr r�cS�|�Srcr)rSrrrr �cSr@rcrr�rrrr rArcS�|||Srcr)rrSr�rrrr rrur�r�zlambda x: x = 2zlambda (None,): None�r%cSrBrcr)rrSrrrrr 
r�r�
cSrwr9rr�rrrr r�cWrwr9rr&rrrr r�c[rwr9rr'rrrr r�cWrwr9rr(rrrr r�c[rwr9rr)rrrr r�cWrwr9rr*rrrr r�cSrwr9rr+rrrr r�c_rwr9rr,rrrr r�cWrwr9rr-rrrr r�cSrwr9rr�rrrr r�c_rwr9rr.rrrr r�c_rwr9rr/rrrr r�c[rwr9rr0rrrr r�c_rwr9rr1rrrr r�c[rwr9rr2rrrr  r�r�r��rr)r�l1�l2�l3�l4�l5�l6�l10Zl11Zl12Zl13Zl14Zl15Zl16Zl17Zl18Zl19Zl20Zl21Zl22Zl23Zl24rrr�test_lambdef�s<


zGrammarTests.test_lambdefcCsd}~dd�}|�dS)Nr'cSs
d}~dSrxrr�rrr�foo)r�z*GrammarTests.test_simple_stmt.<locals>.foor)rrrOrrr�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)	rrrSr��abcr�r�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�rW)z{} fooz{} {{1:foo}}zif 1: {} foozif 1: {} {{1:foo}}zif 1:
    {} foozif 1:
    {} {{1:foo}}zcall to '{}')�sourcerOz(foo.)zinvalid syntax)�formatr;ZassertRaisesRegexrrWr1)r�keywords�cases�keywordZ
custom_msg�caserTrrr�(test_former_statements_refer_to_builtins@s,


���
������z5GrammarTests.test_former_statements_refer_to_builtinscCs�gd�}|\}}}|||f}~~~~~d\}}}~~~d\}}}}	}
}}~~~~	~
~d\}}}}	}
}}~~~~	~
~td�}
|
dd�=tddd	�dS)
Nr�rRZabcdefg�abcdr'rz-del a, (b[0].c, (d.e, f.g[1:2])), [h.i.j], ()r:rW)r|r<)rrQrrSr�rRr�r�r�r�r�r�rr[rrr�
test_del_stmtWs 



zGrammarTests.test_del_stmtcCr�rcrr,rrr�test_pass_stmtq�zGrammarTests.test_pass_stmtcCr�rcrr,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!ra)Zextra_burning_oil�countZ	big_hippor,rr�
test_inner�s�z9GrammarTests.test_break_continue_loop.<locals>.test_inner)r'rr)rrerr,r�test_break_continue_loop�s

z%GrammarTests.test_break_continue_loopcCsFdd�}dd�}dd�}|�|�}|�}|�|dd�t|d	�dS)
NcSr�rcrrrrr�g1�r�z$GrammarTests.test_return.<locals>.g1cSrwrxrrrrr�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 1rF)rrgrhrirrSrrr�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
�rrdrrr�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�dSrkr
rmrrr�test_continue_in_finally�sH

z%GrammarTests.test_continue_in_finallycCsFdd�}|�|�d�dd�}|�|�d�dd�}|�|�d	�dS)
NcS�zWdSYdSrxrrrrrrg(�z/GrammarTests.test_return_in_finally.<locals>.g1r'cSrp)Nr�rrrrrrh/rqz/GrammarTests.test_return_in_finally.<locals>.g2r�cSszddWdSYdS)Nr'rr�rrrrrri6s
z/GrammarTests.test_return_in_finally.<locals>.g3r�r
)rrgrhrirrr�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)NrlrrCr�endr�rrdZcount2rrrrg?s
��
z;GrammarTests.test_break_in_finally_after_return.<locals>.g1FrT)rsr'rc	SsLdD]}dD]}z||W|rnS|rYnwqd||fS)Nrl)rrCrsrrtrrrrhMs��
z;GrammarTests.test_break_in_finally_after_return.<locals>.g2r
�rrgrhrrr�"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'rsr�rrdrrrrg[s�z>GrammarTests.test_continue_in_finally_after_return.<locals>.g1Fr'T)rsr�cSs4dD]}z	|W|rqS|rYqwd|fS)Nrlrsrrwrrrrhhs
�z>GrammarTests.test_continue_in_finally_after_return.<locals>.g2r)rsr'r
rurrr�%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��dVdSrxrrrrrru��
z"GrammarTests.test_yield.<locals>.gcss�dEdHdS�Nrrrrrrrv��cs��dV}dSrxrr�rrrrxrzcss�dEdH}dSr{rr�rrrryr|csry�N)r'r'rrrrrr{rzcsr}r~rr�rrrr|rzzdef g(): yield from (), 1zdef g(): x = yield from (), 1css�ddVfdSrxrrrrrr�r|css�ddEdHfdS�Nr'rrrrrrr���zdef g(): 1, yield 1zdef g(): 1, yield from ()css�tdV�dSrxrrrrrr�r|css�tdVd�dSrxrrrrrr�s�css�tdEdH�dSr{rrrrrr�r�css�tdEdHd�dS)Nrr'rrrrrr���css�d}dddg|�RVdS)N�r�rur�r'rr�rr�rrrr���)r'rr�r�rur�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)rrr|�rrrrr�
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|]}|�qSrrr:rrrr<���HGrammarTests.test_yield_in_comprehensions.<locals>.g.<locals>.<listcomp>r'rrrrrr���z4GrammarTests.test_yield_in_comprehensions.<locals>.gcss�dd�dEdHfD�dS)NcSr�rrr:rrrr<�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)rrr6rrr�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�rcrr,rrr�test_global�r�zGrammarTests.test_globalcsd�d���fdd�}dS)Nrcr�rcrrr
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)Nrrbz%AssertionError not raised by assert 0z+AssertionError not raised by 'assert False')r�rr�r!rPr�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:rWzassert False, "msg")rrrrHr<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:rWz4SyntaxError 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									dSrcrr,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|_dSrc)�max�sofar)rr�rrrrf?s
z/GrammarTests.test_for.<locals>.Squares.__init__cSs
t|j�Src)rPr�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��
IndexErrorrPr��append)rr�nrrrroCs
�
z2GrammarTests.test_for.<locals>.Squares.__getitem__N)r\r]r^rfr�rorrrr�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�?rWz0try:
    pass
except Exception as a[b]:
    pass)r��EOFErrorr6rrr<)rrbrrr�test_tryTs0��
 �"�zGrammarTests.test_trycCs							dSrcrr,rrr�
test_suitemszGrammarTests.test_suitecCs						dSrcrr,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	dSdSrrrrrr�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��||�dSrcr)r=rbr,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:rWz
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��|��dSrcr)r=�rbrrrr6�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:rWz[[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>ru���������r'rr�r�rr�r�cSst|�j|fSrc)rr\r�rrrr 3r	z-GrammarTests.test_selectors.<locals>.<lambda>r�z[1, (1,), (1, 2), (1, 2, 3)])rr�r��modulesr|�sortrrX)	rrr�r�rr�r"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�ryr�)ryr�r�rur�)ryr��threeZfourZfiveZsix>ryr�r�>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�rcrr,rrr�meth1ar�z+GrammarTests.test_classdef.<locals>.C.meth1cSr�rcr)r�argrrr�meth2br�z+GrammarTests.test_classdef.<locals>.C.meth2cSr�rcr)rr�r�rrr�meth3cr�z+GrammarTests.test_classdef.<locals>.C.meth3N)r\r]r^r�r�r�rrrrr�`sr�cSr�rcrr�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�crrcr)r��r�rrr qr!z,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�)r7)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�r;rrrr�
<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)r;r"rrrr<�r=z/GrammarTests.test_listcomps.<locals>.<listcomp>)r�r�z	Coco  nutcSsg|]}d|�qSr�rr:rrrr<�r=)r�r�rr�cSsg|]}|dkr|�qSr�rr:rrrr<��r�csg|]}�D]}||f�qqSrr�r;rr"��strsrrr<��))r'r��r'r��r'r�)rr��rr��rr�)r�r��r�r��r�r�)r�r��r�r��r�r�)rur��rur��rur�cs(g|]}dd��D�D]}||f�qqS)cSsg|]}d|vr|�qS)r�r)r;r�rrrr<�r�z:GrammarTests.test_listcomps.<locals>.<listcomp>.<listcomp>rr�r�rrr<�s()
r�r�r�r�r�r�r�r�r�r�cSsg|]}dd�|��qS)cs�fdd�t�d�D�S)Ncsg|]}�|�qSrrr�r�rrr<�r=zLGrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>.<locals>.<listcomp>r'��ranger�rr�rr �sz8GrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>r)r;rrrrr<�r�rur')r'rr�)r'r�r�)r'r���@�cSsdd�|D�S)NcSs,g|]}|dkrd|kodkn�qS)rrr�rr:rrrr<�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�r;rSrrrr<�r�zUGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>.<listcomp>r'rr:rrrr<��"zJGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>)r'r�rur'rr�r�rur�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)rC�Engine)��Cheeseburger))r'r)r'rC)rrC)r�r�csDg|]\}}�D]\}}�D]\}}||kr||kr||f�qqqSrr)r;ZsnoZsnameZpnoZpnameZsp_snoZsp_pno)�parts�suppartrrr<�s���
))r�r�)r�r�)r�r�)r�r�)rr�r)rr�Zspcsr�r�Z	suppliersrr)rrr�rr�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�rrr:rrrr<�r�z7GrammarTests.test_genexps.<locals>.<genexpr>.<listcomp>rNr�r:rrr�	<genexpr>��� z,GrammarTests.test_genexps.<locals>.<genexpr>r'cSr�rrr:rrrr<�r�z-GrammarTests.test_genexps.<locals>.<listcomp>rz&should produce StopIteration exceptionc3s�|]}�VqdSrcr)r;r�r�rrr�r�zshould produce TypeErrorcs�"�|]}dD]}||fVqqdS)r[Nr�r;rrSrrrr�rr[cS�g|]}dD]}||f�qqS)r[rrrrrr<�r�csr)�xyNrrrrrr�r�abcSr)rrrrrrr<�r�cSr�rrr:rrrr<�r�cs��|]}|VqdSrcrr:rrrr�r�csr
rcrr�rrrr�r�cSr�rrr:rrrr<�r�css�|]}|dVqdS�rNrr:rrrr�r�cSsg|]}|d�qSr�rr:rrrr<�r=css �|]}|dr||VqdSrrr:rrrr�s�cSsg|]
}|dr||�qSr�rr:rrrr<��csr
rcrr:rrrr�r�csr
rcrr�rrrr�r�cSr�rrr:rrrr<�r�csr
rcrr:rrrr�r�csr
rcrr�rrrr�r�csr
rcr�r;r�rrrr�r�cSr�rrr:rrrr<�r�csr
rcrr:rrrr�r�cSr�rrr�rrrr<�r�csr
rcrr
rrrr�r�cSr�rrr:rrrr<�r�cs��|]}|VqdS�TNrr:rrrr�r�csr
rcrr�rrrr�r�csrrrr
rrrr�r�cSr�rrr:rrrr<�r�csrrrr:rrrr�r�css�|]}qdS)FNrr�rrrr�s�csrrrr
rrrr�r�rzfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r�r�nextr!�
StopIterationr6r|�sumr)rrr�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)Nrcsr
rcrr�rrrr�r�z;GrammarTests.test_comprehension_specials.<locals>.<genexpr>ruFc3s*�|]}�rt��D]}||fVq
qdSrcr��r;rr��trrrr�s�(TcSs"g|]
}td�D]}||f�qqS�rur�rrrrr<�r�z<GrammarTests.test_comprehension_specials.<locals>.<listcomp>cSs g|]}|dr|dr|�qSr�rr:rrrr<�s )r'rur�css$�|]
}|dr|dr|VqdS)rr�Nrr:rrrr�s�"cSsg|]\}|�qSrrr:rrrr<�s))r�r)r�r�css�|]\}|VqdSrcrr:rrrr�r�))r�)r�)r)r�r�r)r�rrPr|r�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>.managercSrw�Nrrr,rrr�	__enter__�rzz;GrammarTests.test_with_statement.<locals>.manager.__enter__cWr�rcr)rr�rrr�__exit__�rzz:GrammarTests.test_with_statement.<locals>.manager.__exit__N)r\r]r^rrrrrr�manager��r)�object)rrrrSr�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|�|Srcr�)rb�retrrr�
_checkeval<sz2GrammarTests.test_if_else_expr.<locals>._checkevalcSsg|]}|�r|��qSrrr:rrrr<Cr�z2GrammarTests.test_if_else_expr.<locals>.<listcomp>cSrw)NTrrrrrr Cr�z0GrammarTests.test_if_else_expr.<locals>.<lambda>cSrw�NFrrrrrr Cr�TcSsg|]
}|d�r|d��qSrFrr:rrrr<DrcS�|rdSdS)NFTrr�rrrr DrcSr$)NTFrr�rrrr Drr'ruzcheck 1rzcheck 2r�zcheck 3rr�zcheck 4zcheck 5zcheck 6Fr�rr�g@r
)rr"rrr�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)rrZassertFalserRrrr�test_paren_evaluationUs(z"GrammarTests.test_paren_evaluationcCs>Gdd�d�}|�}|�||d�|d}|�|jd�dS)Nc@r)z'GrammarTests.test_matrix_mul.<locals>.McSrw)Nr�r�rr�rrr�
__matmul__crzz2GrammarTests.test_matrix_mul.<locals>.M.__matmul__cSs
||_|Src)�otherr'rrr�__imatmul__esz3GrammarTests.test_matrix_mul.<locals>.M.__imatmul__N)r\r]r^r(r*rrrrr�brr�r�rv)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�rcrrrrrrorzz8GrammarTests.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>.test2r3)	rr\r�boolr3�co_flags�inspectZCO_COROUTINEr-)rr=r0r3rrr�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�rr8c@r)z*GrammarTests.test_async_for.<locals>.AItercSr�rcrr,rrr�	__aiter__�rzz4GrammarTests.test_async_for.<locals>.AIter.__aiter__c�s�t�rc)�StopAsyncIterationr,rrr�	__anext__���z4GrammarTests.test_async_for.<locals>.AIter.__anext__N)r\r]r^r9r;rrrr�AIter�rr=c�sN���2z3dHW}q6��2z3dHW\}}q6��2z3dHW}q6	��rcrr�r=r8rrrO�s����z(GrammarTests.test_async_for.<locals>.foo�r�r�send�rrOrr>r�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�rrrrr8�rr8c@r)z-GrammarTests.test_async_with.<locals>.managerc�r1rrr,rrr�
__aenter__�r<z8GrammarTests.test_async_with.<locals>.manager.__aenter__c�r1r#r)r�excrrr�	__aexit__�r<z7GrammarTests.test_async_with.<locals>.manager.__aexit__N)r\r]r^rCrErrrrr�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��rcrr
�r8rrrrO�s,�(�(�(� R� R� :��z)GrammarTests.test_async_with.<locals>.foor?rArrFr�test_async_with�s"�zGrammarTests.test_async_withN)Lr\r]r^r_r�test.support.warnings_helperrrrrsr}r~r�r�r�r�r�r�r�r�r�r8rNrPrSrZr\r]r_rcrfrjrnrorrrvrxr�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�rrrr r%r&r,r7rBrGrrrrrq8s�.		
y'45'



R#!?#D
rq�__main__)r_rrrHrr6rIrr(Ztest.ann_moduler�r��collectionsrr=r	r0r2ZTestCaserr{r�rarqr\�mainrrrr�<module>sH7D	
�