Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.145.125.181
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_grammar.cpython-310.pyc
o

`bs��@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/python-3.10/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_literalscsX�fdd�}�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�t���.t�dt�|d�|d�|d �|d!�|d"�|d#�|d$�|d%�Wd�n1s�wY|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�|dD�|dE�|dF�dS)GNcs<��t��t|dd�Wd�dS1swYdS)N�
<testcase>r)ZassertWarnsr+�compile��testr,rrr6�s"�z8TokenTests.test_end_of_numerical_literals.<locals>.checkc	srtjdd��#}��t��t|dd�Wd�n1swYWd�n1s,wY��|g�dS)NT)�recordr8r)r(r)rrr9r)r;�wr,rr�check_error�s���z>TokenTests.test_end_of_numerical_literals.<locals>.check_errorz0xfand xz0o7and xz0b1and xz9and xz0and xz1.and xz1e3and xz1jand xz0xfor xz0o7or xz0b1or xz9or xz0or xz1.or xz1e3or xz1jor xz0xfin xz0o7in xz0b1in xz9in xz0in xz1.in xz1e3in xz1jin xr&z0xfis xz0o7is xz0b1is xz9is xz0is xz1.is xz1e3is xz1jis xz0xfif x else yz0o7if x else yz0b1if x else yz9if x else yz0if x else yz
1.if x else yz1e3if x else yz
1jif x else yzx if 0xfelse yzx if 0o7else yzx if 0b1else yzx if 9else yzx if 0else yz
x if 1.else yzx if 1e3else yz
x if 1jelse yz[0x1ffor x in ()]z[0x1for x in ()]z[0xfor x in ()]z[0o7for x in ()]z[0b1for x in ()]z[9for x in ()]z[1.for x in ()]z[1e3for x in ()]z[1jfor x in ()]Z0xfspamZ0o7spamZ0b1spamZ9spamZ0spamz1.spamZ1e3spamZ1jspam)r(r)r*�
SyntaxWarning)rr6r>rr,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_ellipsisVszTokenTests.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)rrr9ZassertIn�str�	exception)rZsamplesr"�cmrrr�test_eof_error[s��zTokenTests.test_eof_errorN)�__name__�
__module__�__qualname__�test.supportrrr#r$r%r-r4r7r@rJrLrQrrrrrhs
$
V(rZvar_annot_globalc@�$eZdZdd�Zdd�Zdd�ZdS)�CNScC�
i|_dS�N��_dctr,rrr�__init__g�
zCNS.__init__cCs||j|��<dSrY)r[�lower�r�item�valuerrr�__setitem__iszCNS.__setitem__cC�
|j|SrYrZ�rr`rrr�__getitem__kr]zCNS.__getitem__N�rRrSrTr\rbrerrrrrWfsrWc@sDeZdZddlmZddlmZddlmZdd�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)e*�+dIdJ�dKdL��Z,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�S)��GrammarTestsrrr)�check_no_warningscCstd�}dS)Nz	1, 0 or 1)rrrrr�test_eval_input~�zGrammarTests.test_eval_inputcCs@d}dg}dd�}ttgdd||�d<|�|dg�dS)N��*cS�dS�Nr'rrrrr�one��z/GrammarTests.test_var_annot_basics.<locals>.onerr')�int�listr)rZvar1Zmy_lstrorrr�test_var_annot_basics�s
z"GrammarTests.test_var_annot_basicscCs^t|d�t|d�t|d�t|d�t|d�t|d�t|d�t|d�t|d	�dS)
Nz
def f: intzx: int: strzdef f():
    nonlocal x: int
z[x, 0]: int
z	f(): int
z	(x,): intz"def f():
    (x, y): int = (1, 2)
z!def f():
    x: int
    global x
z!def f():
    global x
    x: int
rr,rrr�test_var_annot_syntax_errors�s







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�f�sz6GrammarTests.test_var_annot_basic_semantics.<locals>.fcS�dSrYrrrrr�f_OK��z9GrammarTests.test_var_annot_basic_semantics.<locals>.f_OKcSst|�dSrY��print�rrrr�fbad�rjz9GrammarTests.test_var_annot_basic_semantics.<locals>.fbadcSstt�dSrY)rZno_such_globalrrrr�f2bad�rjz: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
||_dSrYr�rrrrr\�r]z?GrammarTests.test_var_annot_basic_semantics.<locals>.C.__init__N)	rRrSrTrq�__annotations__r"rN�zr\rrrr�C�s

r�)r�r"c@seZdZUde_edS)z9GrammarTests.test_var_annot_basic_semantics.<locals>.CBadrN)rRrSrTZno_such_name_definedr�rqrrrr�CBad�s
r�c@s eZdZUeed<ge_edS)z:GrammarTests.test_var_annot_basic_semantics.<locals>.Cbad2rN)rRrSrTrqr�rrIrrrrrr�Cbad2�s
r�)
r�ZeroDivisionErrorZno_nameZdoes_not_existr3rr��UnboundLocalError�	ExceptionZassertIsrrqrN)	rrzr|r�r��er�r�r�rrr�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�Nr�)rW)�metacls�name�bases�kwdsrrr�__prepare__��
zJGrammarTests.test_var_annot_metaclass_semantics.<locals>.CMeta.__prepare__N)rRrSrT�classmethodr�rrrr�CMeta�sr�c@seZdZUded<dS)z;GrammarTests.test_var_annot_metaclass_semantics.<locals>.CC�ANNOTZXXN)rRrSrTr�rrrr�CC�s
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'rrIrz�u�{)Z123�o)rr;r��
ann_modulerqrN�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_module3rk)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)rMrrqr�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>.CNS2cSrXrYrZr,rrrr\�r]z>GrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__init__c�||j|<|�|<dSrYrZr_��	nonloc_nsrrrb�
zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__setitem__cSrcrYrZrdrrrrer]zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__getitem__Nrfrr�rr�CNS2�sr�z
x: int = 1)rWrMrrqrNrr�)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�rZr,)�cnsrrr\�z:GrammarTests.test_var_annot_refleak.<locals>.CNS2.__init__cr�rYrZr_r�rrrbr�z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__setitem__cSrcrYrZrdrrrrer]z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__getitem__Nrfr�r�r�rrr�sr�zX: strr)rWrMrrN)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, 2rruzdef f():
    x: int = yieldrzr'�r��rk)rwrx�cr�zx: Tuple[int, ...] = a,*b,c�r'rr�r�rk)rMrrrr�r�)rr�Zstmtrrr�test_var_annot_rhss


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{rYrrrrr�f15r}z%GrammarTests.test_funcdef.<locals>.f1rcSr{rYr�Zone_argumentrrr�f29r}z%GrammarTests.test_funcdef.<locals>.f2cSr{rYr��twoZ	argumentsrrr�f3:r}z%GrammarTests.test_funcdef.<locals>.f3r�r�cSr{rYr)Zone_argrrr�a1=r}z%GrammarTests.test_funcdef.<locals>.a1cSr{rYr)r��argsrrr�a2>r}z%GrammarTests.test_funcdef.<locals>.a2cWr{rYr��restrrr�v0?r}z%GrammarTests.test_funcdef.<locals>.v0cWr{rYr�rwr�rrr�v1@r}z%GrammarTests.test_funcdef.<locals>.v1cWr{rYr�rwrxr�rrr�v2Ar}z%GrammarTests.test_funcdef.<locals>.v2r'rr�r�rk���rrcSr{rYr�rwrrr�d01Wr}z&GrammarTests.test_funcdef.<locals>.d01�r'rwcSr{rYrrvrrr�d11_r}z&GrammarTests.test_funcdef.<locals>.d11rxcSr{rYr�rwrxr�rrr�d21cr}z&GrammarTests.test_funcdef.<locals>.d21�r'rr��rr��r�r�cSr{rYrrvrrr�d02jr}z&GrammarTests.test_funcdef.<locals>.d02ru�rrvcSr{rYrr�rrr�d12rr}z&GrammarTests.test_funcdef.<locals>.d12cSr{rYr�rwrxr��drrr�d22vr}z&GrammarTests.test_funcdef.<locals>.d22cWr{rYrr�rrr�d01vzr}z'GrammarTests.test_funcdef.<locals>.d01v)r'rr�r�cWr{rYrr�rrr�d11v�r}z'GrammarTests.test_funcdef.<locals>.d11vcWr{rYr�rwrxr�r�rrr�d21v�r}z'GrammarTests.test_funcdef.<locals>.d21vcWr{rYrr�rrr�d02v�r}z'GrammarTests.test_funcdef.<locals>.d02vr�cWr{rYrr�rrr�d12v�r}z'GrammarTests.test_funcdef.<locals>.d12v�r�r�rkcWr{rYr)rwrxr�r�r�rrr�d22v�r}z'GrammarTests.test_funcdef.<locals>.d22vr�r&rsfooz/Bytes should not work as keyword argument namescS�|SrYr��keyrrr�pos0key1�r}z+GrammarTests.test_funcdef.<locals>.pos0key1�dr�)�k2cSs||||fSrYr)�p1�p2�k1r�rrr�pos2key2��z+GrammarTests.test_funcdef.<locals>.pos2key2)r���)r�r�)r�r�c[s|||||fSrYr)r�r�r�r��kwargrrr�pos2key2dict��z/GrammarTests.test_funcdef.<locals>.pos2key2dict)r��tokwarg1�tokwarg2)r�r�r�zdef f(*): passzdef f(*,): passzdef f(*, **kwds): passc_s||fSrYr)r��kwargsrrrrz�sz$GrammarTests.test_funcdef.<locals>.f�rrI)r'r�r�zf(1, x=2, *(3,4), x=5)Z	scrambledZfried)�eggs�spamr�r�z
f(*g(1=2))zf(**g(1=2))�returncSr{rYrr�rrrrz�r}cSr{rYrr�rrrrz�r}cSr{rYrr�rrrrz�r}rDcSr{rYrr�rrrrz�r}cWr{rYrr�rrrrz�r}c[r{rYrr�rrrrz�r}rIcSr{rYrr�rrrrz�r}cSr{rYrr�rrrrz�r}cSr{rYrr�rrrrz�r})rxr�cSr{rYrr�rrrrz�r}r��gcWr{rYr)rwrxr�r�r�rzr�rrrrz�r})rxr�r�r��
��i�j�hr��k��c_r{rYr�rwrxr�r�r�rzr�r�r�r�rrrrrz�rp)rxr�r�r�r�r�rr�rzc_r{rYrrrrrrz�rp)	rxr�r�rzr�r�r�rr�c@seZdZddd�ZdS)z'GrammarTests.test_funcdef.<locals>.Spam�	_Spam__kwr'cSr{rYr)rrrrrrz�rpz)GrammarTests.test_funcdef.<locals>.Spam.fN)rr')rRrSrTrzrrrr�Spam�src@�eZdZdS)z&GrammarTests.test_funcdef.<locals>.HamN�rRrSrTrrrr�Ham�r�rrcSr�rYrr�rrr�null�r}z'GrammarTests.test_funcdef.<locals>.nullcSr{rYrr�rrrrz�rpFcSr{rYrr�rrrrz�rpcSr{rYrr�rrrrz�rpc��|�SrYr�rz)r	rr�<lambda>��z+GrammarTests.test_funcdef.<locals>.<lambda>cSr{rYrr�rrrrz�rp.cSr{rYrr�rrrrzrpcSr{rYrr�rrrrzrpcSr{rYrr�rrrrzrpc��SrYrr��closurerrrz
r}crrYrr�rrrrzr}�rcrrYrrrrrrzr}crrYrrrrrrz
r}cSr{rYrr�rrrrzr}cWr{rYr�r�rrrrzr}c[r{rYr�r�rrrrzr}cWr{rYr�rwr�rrrrzr}c[r{rYr�rwr�rrrrzr}cWr{rYr�rxr�rrrrzr}cSr{rYr�rxrrrrzr}c_r{rYr�r�r�rrrrzr}cWr{rYr�rwrxr�rrrrzr}cSr{rYrrvrrrrzr}c_r{rYr�rwr�r�rrrrzr}c_r{rYr�rxr�r�rrrrzr}c[r{rYr�rxr�rrrrzr}c_r{rYr�rwrxr�r�rrrrzr}c[r{rYr�rwrxr�rrrrzr}r�)rD)rIr�)rxr'r�r)r�rrxr')r�rk)rxr'r�rr�r�r�r�)rxr'r�rr�r�r�r�r�r�r�rrrr�r)r�__code__�co_varnamesr(r)r*�BytesWarningrN�	TypeErrorr!rrrrrrr�rqr�rz�__call__)rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rzrrr�r)rr	r�test_funcdef(s�





























�
��	
 � ��





�
�
���(�
���







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))NcSrm�Nrrrrrrr"r}z+GrammarTests.test_lambdef.<locals>.<lambda>rcSsttSrY)rwr�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�rYr�r�rrrr'r}cS�|�SrYr)rIrrrr'�cSr,rYrr�rrrr'r-rcS�|||SrYr)rrIr�rrrr)r�rkr�r�zlambda x: x = 2zlambda (None,): None�rcSr.rYr)rrIrrrrr.r��r��
cSrmr%rr�rrrr3r}cWrmr%rrrrrr4r}c[rmr%rrrrrr5r}cWrmr%rrrrrr6r}c[rmr%rrrrrr7r}cWrmr%rrrrrr8r}cSrmr%rrrrrr9r}c_rmr%rrrrrr:r}cWrmr%rrrrrr;r}cSrmr%rrvrrrr<r}c_rmr%rrrrrr=r}c_rmr%rrrrrr>r}c[rmr%rrrrrr?r}c_rmr%rrrrrr@r}c[rmr%rrrrrrAr}r�r��rr)r�l1�l2�l3�l4�l5�l6�l10Zl11Zl12Zl13Zl14Zl15Zl16Zl17Zl18Zl19Zl20Zl21Zl22Zl23Zl24rrr�test_lambdef s<


zGrammarTests.test_lambdefcCsd}~dd�}|�dS)Nr'cSs
d}~dSrnrr�rrr�fooJr�z*GrammarTests.test_simple_stmt.<locals>.foor)rrr;rrr�test_simple_stmtGs
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)	rrrIr��abcrwrxr��xyzrrr�test_expr_stmtRs

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)rrM)z{} fooz{} {{1:foo}}zif 1: {} foozif 1: {} {{1:foo}}zif 1:
    {} foozif 1:
    {} {{1:foo}}zcall to '{}')�sourcer;z(foo.)zinvalid syntax)�formatZsubTestZassertRaisesRegexrrMr1)r�keywords�cases�keywordZ
custom_msg�caser@rrr�(test_former_statements_refer_to_builtinsas,


���
������z5GrammarTests.test_former_statements_refer_to_builtinscCs�gd�}|\}}}|||f}~~~~~d\}}}~~~d\}}}}	}
}}~~~~	~
~d\}}}}	}
}}~~~~	~
~td�}
|
dd�=tddd	�dS)
Nr�r>Zabcdefg�abcdr'rz-del a, (b[0].c, (d.e, f.g[1:2])), [h.i.j], ()r8rM)rrr9)rr=rrIr�r>rwrxr�r�r�rzr�rGrrr�
test_del_stmtxs 



zGrammarTests.test_del_stmtcCr{rYrr,rrr�test_pass_stmt��zGrammarTests.test_pass_stmtcCr{rYrr,rrr�test_break_stmt�rJzGrammarTests.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}Wq|d8}Wq�|dks'|dkr.��d�dSdS)Nrr'z1continue then break in try/except in loop broken!rM)Zextra_burning_oil�countZ	big_hippor,rr�
test_inner�s�z9GrammarTests.test_break_continue_loop.<locals>.test_inner)r'rr)rrQrr,r�test_break_continue_loop�s

z%GrammarTests.test_break_continue_loopcCsFdd�}dd�}dd�}|�|�}|�}|�|dd�t|d	�dS)
NcSr{rYrrrrr�g1�r}z$GrammarTests.test_return.<locals>.g1cSrmrnrrrrr�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 1r2)rrSrTrUrrIrrr�test_return�szGrammarTests.test_returncCs4d}|dkr|d7}zWqY|�|d�d}|dkr(|d7}zWq(Y|�|d�d}|dkrC|d7}zddWqCY|�|d�dD]}|�|d�zWq\Y|�|d�dD]}|�|d�zWquY|�|d�dD]}|�|d�zddWq�Y|�|d�dS�Nrrr'�rr'r
�rrPrrr�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�dSrWr
rYrrr�test_continue_in_finallysH

z%GrammarTests.test_continue_in_finallycCsFdd�}|�|�d�dd�}|�|�d�dd�}|�|�d	�dS)
NcS�zWdSYdSrnrrrrrrSI�z/GrammarTests.test_return_in_finally.<locals>.g1r'cSr\)Nr�rrrrrrTPr]z/GrammarTests.test_return_in_finally.<locals>.g2r�cSszddWdSYdS)Nr'rr�rrrrrrUWs
z/GrammarTests.test_return_in_finally.<locals>.g3r�r
)rrSrTrUrrr�test_return_in_finallyHsz#GrammarTests.test_return_in_finallycCsTdd�}|�|d�d�|�|d�d�dd�}|�|d�d�|�|d�d�dS)	NcSsPdD] }d}|dkr"|d7}z||W|rq"S|r!Yq"wqd||fS)NrXrr/r��endr�rrPZcount2rrrrS`s
��
z;GrammarTests.test_break_in_finally_after_return.<locals>.g1Fr�T)r_r'r�c	SsLdD]}dD]}z||W|rq S|rYq wqd||fS)NrX)r�r/r_rr`rrrrTns��
z;GrammarTests.test_break_in_finally_after_return.<locals>.g2r
�rrSrTrrr�"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'r_r�rrPrrrrS|s�z>GrammarTests.test_continue_in_finally_after_return.<locals>.g1Fr'T)r_r�cSs4dD]}z	|W|rqS|rYqwd|fS)NrXr_rrcrrrrT�s
�z>GrammarTests.test_continue_in_finally_after_return.<locals>.g2r)r_r'r
rarrr�%test_continue_in_finally_after_returnzs
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��dVdSrnrrrrrr����
z"GrammarTests.test_yield.<locals>.gcss�dEdHdS�Nrrrrrrr����cs��dV}dSrnrr�rrrr��rfcss�dEdH}dSrgrr�rrrr��rhcsre�N)r'r'rrrrrr��rfcsrirjrr�rrrr��rfzdef g(): yield from (), 1zdef g(): x = yield from (), 1css�ddVfdSrnrrrrrr��rhcss�ddEdHfdS�Nr'rrrrrrr����zdef g(): 1, yield 1zdef g(): 1, yield from ()css�tdV�dSrnrrrrrr��rhcss�tdVd�dSrnrrrrrr��s�css�tdEdH�dSrgrrrrrr��rlcss�tdEdHd�dS)Nrr'rrrrrr����css�d}dddg|�RVdS)N�r�rkr�r'rr�rr�rrrr����)r'rr�r�rkr�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)rrrr�rr�rrr�
test_yield�s6











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)NcSrsrrr&rrrr(�rtrurrrrrrr��roz 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{rYrr,rrr�test_global�r}zGrammarTests.test_globalcsd�d���fdd�}dS)Nrcr{rYrrr�rrrz�r}z%GrammarTests.test_nonlocal.<locals>.fr)rrzrr�r�
test_nonlocal�szGrammarTests.test_nonlocalc
Cs�		dd�sJ�	z	Wnty#}z|�d�WYd}~nd}~wwzWdSty?}z|�d�WYd}~dSd}~ww)	Nr'cSr�rYrr�rrrr�r}z*GrammarTests.test_assert.<locals>.<lambda>cSs|dSrnrr�rrrr�r
Tz6'assert True' should not have raised an AssertionErrorzthis should always passz;'assert True, msg' should not have raised an AssertionError)�AssertionErrorr!�rr�rrr�test_assert�s ����zGrammarTests.test_assertTz Won't work if __debug__ is Falsec
Cs~zJd��ty}z|�|jdd�WYd}~nd}~wwzJ�ty>}z|�t|j�d�WYd}~dSd}~ww)NrrN)r�rr�r!rFr�rrr�test_assert_failuress�� ��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"r8rMzassert False, "msg")rrhr?r9r,rrr�test_assert_syntax_warningss���"�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)	N�errorzassert x, "msg" r8rMz4SyntaxError incorrectly raised for 'assert x, "msg"'r�r�r�)r(r)r*r?r9rr!rr,rrr�,test_assert_warning_promotes_to_syntax_error)s&
�����
"�z9GrammarTests.test_assert_warning_promotes_to_syntax_errorcCs									dSrYrr,rrr�test_if>szGrammarTests.test_ifcCs 			d}	d}|�|d�dS)Nrr'rr
rrrr�
test_whileKszGrammarTests.test_whilecCs�dD]}qdD]\}}}q	Gdd�d�}d}|d�D]}||}q|dkr+|�d�g}d	D]\}|�|�q/|�|gd��dS)
Nr�rc@rV)z&GrammarTests.test_for.<locals>.SquarescSs||_g|_dSrY)�max�sofar)rr�rrrr\`s
z/GrammarTests.test_for.<locals>.Squares.__init__cSs
t|j�SrY)rFr�r,rrr�__len__cs
z.GrammarTests.test_for.<locals>.Squares.__len__cSsZd|kr|jkst�t�t|j�}||kr(|j�||�|d}||ks|j|S)Nrr')r��
IndexErrorrFr��append)rr��nrrrreds
�
z2GrammarTests.test_for.<locals>.Squares.__getitem__N)rRrSrTr\r�rerrrr�Squares_sr�rr�izfor over growing sequence)r�r�r�)r!r�r)rr�r�rr�r�r�resultrrr�test_forZs


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�?rMz0try:
    pass
except Exception as a[b]:
    pass)r��EOFErrorr"rrr9)rrNrrr�test_tryus0��
 �"�zGrammarTests.test_trycCs							dSrYrr,rrr�
test_suite�szGrammarTests.test_suitecCs						dSrYrr,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	dSdSrkrrrrr�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)N�"is" with a literalcs��||�dSrYr)r;rNr,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 Noner8rMz
x is Falsez	x is Truezx is ...)r��r(r)r*r?r9r5rr,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��|��dSrYrr:�rNrrrr6�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)]r8rMz[[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_ops!r�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_ops,r�z$GrammarTests.test_multiplicative_opscCsd}d}d}d}d}dS)Nr'r*���r�rrrrr�test_unary_ops2s
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*rk���������r'rr�r�rur�r�cSst|�j|fSrY)rrRr�rrrrTr�z-GrammarTests.test_selectors.<locals>.<lambda>r�z[1, (1,), (1, 2), (1, 2, 3)])rr{r|�modulesrr�sortrrN)	rrr{r�rrwr"r��Lrrr�test_selectors9s,
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�ror�)ror�r�rkr�)ror��threeZfourZfiveZsix>r�r�ro>rr�r�rr�rrrrr�
test_atomsWs,



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>.BNrrrrr�B|r�r�c@r)z&GrammarTests.test_classdef.<locals>.B2Nrrrrr�B2}r�r�c@r)z&GrammarTests.test_classdef.<locals>.C1Nrrrrr�C1~r�r�c@r)z&GrammarTests.test_classdef.<locals>.C2Nrrrrr�C2r�r�c@r)z%GrammarTests.test_classdef.<locals>.DNrrrrr�D�r�r�c@rV)z%GrammarTests.test_classdef.<locals>.CcSr{rYrr,rrr�meth1�r}z+GrammarTests.test_classdef.<locals>.C.meth1cSr{rYr)r�argrrr�meth2�r}z+GrammarTests.test_classdef.<locals>.C.meth2cSr{rYr)rr�r�rrr�meth3�r}z+GrammarTests.test_classdef.<locals>.C.meth3N)rRrSrTr�r�r�rrrrr��sr�cSr�rYrr�rrr�class_decorator�r}z3GrammarTests.test_classdef.<locals>.class_decoratorc@r)z%GrammarTests.test_classdef.<locals>.GNrrrrr�G��r�Fc@r)z%GrammarTests.test_classdef.<locals>.HNrrrrr�H�r�r�c@r)z%GrammarTests.test_classdef.<locals>.INrrrrr�I�r�r�cr
rYr)r��r�rrr�r
z,GrammarTests.test_classdef.<locals>.<lambda>c@r)z%GrammarTests.test_classdef.<locals>.JNrrrrr�J�r�r�.r'c@r)z%GrammarTests.test_classdef.<locals>.KNrrrrr�K�r�r�c@r)z%GrammarTests.test_classdef.<locals>.LNrrrrrr��r�r�rc@r)z%GrammarTests.test_classdef.<locals>.MNrrrrrr��r�r�)r#)rr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�
test_classdefzs*

zGrammarTests.test_classdefcCs*gd�}|�dd�|D�dddd��dS)Nr�cSsi|]}||d�qSr�r�r'r�rrr�
<dictcomp>�sz/GrammarTests.test_dictcomps.<locals>.<dictcomp>rr�r�r
)r�numsrrr�test_dictcomps�s"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'r�r"��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�)rkr��rkr��rkr�cs(g|]}dd��D�D]}||f�qqS)cSsg|]}d|vr|�qS)r�r)r'rzrrrr(�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'r�rrrr(�r�rkr')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)cSrsrr�r'rIrrrr(�rtzUGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>.<listcomp>r'rr&rrrr(��"zJGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>)r'r�rkr'rr�r�rkr�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)r'ZsnoZsnameZpnoZpnameZsp_snoZsp_pno)�parts�suppartrrr(�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)cSrsrrr&rrrr(�rtz7GrammarTests.test_genexps.<locals>.<genexpr>.<listcomp>r�Nr�r&rrr�	<genexpr>��� z,GrammarTests.test_genexps.<locals>.<genexpr>r'cSrsrrr&rrrr(�rtz-GrammarTests.test_genexps.<locals>.<listcomp>r�z&should produce StopIteration exceptionc3s�|]}�VqdSrYr)r'r�r�rrr��rlzshould produce TypeErrorcs�"�|]}dD]}||fVqqdS)rGNr�r'rrIrrrr��r�rGcS�g|]}dD]}||f�qqS)rGrr�rrrr(�r�csr�)�xyNrr�rrrr��r��abcSr�)r�rr�rrrr(�r�cSrsrrr&rrrr(�rtcs��|]}|VqdSrYrr&rrrr��rlcsr�rYrr�rrrr��rlcSrsrrr&rrrr(�rtcss�|]}|dVqdS�rNrr&rrrr��rvcSsg|]}|d�qSr�rr&rrrr(�r)css �|]}|dr||VqdSr�rr&rrrr��s�cSsg|]
}|dr||�qSr�rr&rrrr(��csr�rYrr&rrrr��rlcsr�rYrr�rrrr��rlcSrsrrr&rrrr(�rtcsr�rYrr&rrrr��rlcsr�rYrr�rrrr��rlcsr�rYr�r'r�rrrr��rlcSrsrrr&rrrr(�rtcsr�rYrr&rrrr��rlcSrsrrr�rrrr(�rtcsr�rYrr�rrrr��rlcSrsrrr&rrrr(�rtcs��|]}|VqdS�TNrr&rrrr��rlcsr�rYrr�rrrr��rlcsr�rrr�rrrr��rlcSrsrrr&rrrr(�rtcsr�rrr&rrrr�rlcss�|]}qdS)FNrr�rrrr�s�csr�rrr�rrrr�rlrzfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r�r�nextr!�
StopIterationr"rr�sumr)rr�rxrr�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)Nr�csr�rYrr�rrrr�rlz;GrammarTests.test_comprehension_specials.<locals>.<genexpr>rkFc3s*�|]}�rt��D]}||fVq
qdSrYr��r'r�r���trrrr�
s�(TcSs"g|]
}td�D]}||f�qqS�rkr�rrrrr(r�z<GrammarTests.test_comprehension_specials.<locals>.<listcomp>cSs g|]}|dr|dr|�qSr�rr&rrrr(s )r'rkr�css$�|]
}|dr|dr|VqdS)rr�Nrr&rrrr�s�"cSsg|]\}|�qSrrr&rrrr(s))r�r)r�rncss�|]\}|VqdSrYrr&rrrr�rm))r�)r�)r)r�r�r)r�rrFrrrqrrr�test_comprehension_specialss ""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>.managercSrm�Nrurr,rrr�	__enter__rpz;GrammarTests.test_with_statement.<locals>.manager.__enter__cWr{rYr)rr�rrr�__exit__rpz:GrammarTests.test_with_statement.<locals>.manager.__exit__N)rRrSrTrr
rrrr�manager�r)�object)rrrrIr�rrr�test_with_statements�����������������������������������������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|�|S)z@helper to check that evaluation of expressions is done correctlyr~)rN�retrrr�
_checkeval]sz2GrammarTests.test_if_else_expr.<locals>._checkevalcSsg|]}|�r|��qSrrr&rrrr(dr�z2GrammarTests.test_if_else_expr.<locals>.<listcomp>cSrm)NTrrrrrrdr}z0GrammarTests.test_if_else_expr.<locals>.<lambda>cSrm�NFrrrrrrdr}TcSsg|]
}|d�r|d��qS)Frr&rrrr(er�cS�|rdSdS)NFTrr�rrrrer�cSr)NTFrr�rrrrer�r'rkzcheck 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)rrZassertFalserHrrr�test_paren_evaluationvs(z"GrammarTests.test_paren_evaluationcCs>Gdd�d�}|�}|�||d�|d}|�|jd�dS)Nc@r
)z'GrammarTests.test_matrix_mul.<locals>.McSrm)Nr�r�rr�rrr�
__matmul__�rpz2GrammarTests.test_matrix_mul.<locals>.M.__matmul__cSs
||_|SrY)�otherrrrr�__imatmul__�sz3GrammarTests.test_matrix_mul.<locals>.M.__imatmul__N)rRrSrTrrrrrrr��rr�r�rl)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{rYrrrrrr�rpz8GrammarTests.test_async_await.<locals>.test.<locals>.sum)Zsomeobj)rrrrr;�s�z+GrammarTests.test_async_await.<locals>.testr;cSst|dd�|S)N�_markedT)�setattr)�funcrrr�	decorator�sz0GrammarTests.test_async_await.<locals>.decoratorc���dS)N�rrrrr�test2�s�z,GrammarTests.test_async_await.<locals>.test2r$)	rrRr�boolr�co_flags�inspectZCO_COROUTINEr)rr;r!r$rrr�test_async_await�s
zGrammarTests.test_async_awaitcshGdd�dt��Gdd�d����fdd�}|����|��d�Wd�dS1s-wYdS)Nc@r)z)GrammarTests.test_async_for.<locals>.DoneNrrrrr�Done�r�r)c@r
)z*GrammarTests.test_async_for.<locals>.AItercSr�rYrr,rrr�	__aiter__�rpz4GrammarTests.test_async_for.<locals>.AIter.__aiter__c�s�t�rY)�StopAsyncIterationr,rrr�	__anext__���z4GrammarTests.test_async_for.<locals>.AIter.__anext__N)rRrSrTr*r,rrrr�AIter�rr.c�sN���2z3dHW}q6��2z3dHW\}}q6��2z3dHW}q6	��rYrr��r.r)rrr;�s����z(GrammarTests.test_async_for.<locals>.foo�r�r�send�rr;rr/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>.DoneNrrrrrr)�r�r)c@r
)z-GrammarTests.test_async_with.<locals>.managerc�r"rrr,rrr�
__aenter__�r-z8GrammarTests.test_async_with.<locals>.manager.__aenter__c�r"rr)r�excrrr�	__aexit__�r-z7GrammarTests.test_async_with.<locals>.manager.__aexit__N)rRrSrTr4r6rrrrr�rrc
�s���4IdH�Wd�IdHq1IdHswY��4IdH�}Wd�IdHq;1IdHs6wY��4IdH�
\}}Wd�IdHqZ1IdHsUwY��4IdH�(��4IdH�Wd�IdHq1IdHszwYWd�IdHq�1IdHs�wY��4IdH�(}��4IdH�}Wd�IdHq�1IdHs�wYWd�IdHq�1IdHs�wY��4IdH�)}��4IdH�Wd�IdHq�1IdHs�wYWd�IdH��1IdH�swY��rYrr��r)rrrr;�s,�(�(�(� R� R� :��z)GrammarTests.test_async_with.<locals>.foor0r2rr7r�test_async_with�s"�zGrammarTests.test_async_withN)KrRrSrTrUr�test.support.warnings_helperrrhrirsrtr�r�r�r�r�r�r�r�r$r:r<r?rFrHrIrKrOrRrVrZr[r^rbrdrrrwrzr~rr�r��unittestZ
skipUnlessr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr	rrrrr(r3r8rrrrrgos�.		
y'45'



R#!?#D
rg�__main__)rUrrr9rr'r:rr(Ztest.ann_moduler�r��collectionsrr;r	r0r2ZTestCaserrqr�rWrgrR�mainrrrr�<module>sF7{	s�
© 2025 GrazzMean