Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_grammar.cpython-310.pyc
o

�9j��@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)�0_0_0�4_2�1_0000_0000�0b1001_0100�0xffff_ffff�0o5_7_7z	1_00_00.5z1_00_00.5e5�1_00_00e5_1�1e1_0z.1_4z.1_4e1�0b_0�0x_f�0o_5�1_00_00jz
1_00_00.5j�1_00_00e5_1jz.1_4jz(1_2.5+3_3j)z(.5_6j))(�0_�42_z1.4j_�0x_�0b1_�0xf_�0o5_z
0 if 1_Else 1�0_b0�0_xf�0_o5�0_7�09_99�	4_______2z0.1__4z0.1__4j�0b1001__0100�0xffff__ffff�0x___�0o5__77�1e1__0�1e1__0jz1_.4z1_.4jz1._4z1._4jz._5z._5jz1.0e+_1z1.0e+_1jz1.4_jz1.4e5_j�1_e1z1.4_e1z1.4_e1j�1e_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�r2�(/usr/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��)�
2147483648�
0o40000000000�0x100000000�"0b10000000000000000000000000000000z(OverflowError on huge integer literal %rl����l���������l����)�9223372036854775808�0o2000000000000000000000�0x10000000000000000�A0b100000000000000000000000000000000000000000000000000000000000000zWeird maxsize value %r)
r.�type�assertRaises�SyntaxError�eval�sysr8�
assertTrue�
OverflowError�fail)r0r8�sr1r2r2r3�test_plain_integersvs@����zTokenTests.test_plain_integerscCs$d}d}d}d}d}d}d}d}dS)Nrr=l���?l�
~��l!]cll�����r2r/r2r2r3�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�@r2r/r2r2r3�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�DeprecationWarningr.rErCrD�r0r2r2r3� test_float_exponent_tokenization�s
�z+TokenTests.test_float_exponent_tokenizationc	CsPtD]}|�t|�t|�dd���qtD]	}|�tt|�q|�ttd�dS)N�_��_0)�VALID_UNDERSCORE_LITERALSr.rE�replace�INVALID_UNDERSCORE_LITERALSrCrD�	NameError)r0�litr2r2r3�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)N�0b12z#invalid digit '2' in binary literal�0b1_2�0b2rzinvalid binary literal�0b�0o18z"invalid digit '8' in octal literal�0o1_8�0o8�0o1_zinvalid octal literal�0o�0x1_zinvalid hexadecimal literalr7�1_zinvalid decimal literal�012z`leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integersz1.2_�1e2_z1e+r�r0�checkr2r2r3�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>rE)	�subTestrPrQrCrD�compiler.�assertWarnsrS)�test�error�wrTr2r3rm�s"������"�z8TokenTests.test_end_of_numerical_literals.<locals>.check)�0xf�0o7�0b1�9�0z1.�1e3�1jrqrEzand xrx)rvzor xr|zin xznot in xrN�"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)rsrPrQ�filterwarnings�
SyntaxWarning)r0rm�numr2rTr3�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)NrWr�'rO�'�"�"zdoesn't "shrink" does it�zdoes "shrink" doesn't itz2
The "quick"
brown fox
jumps over
the 'lazy' dog.
)rG�len�ordr.�r0r1�yr2r2r3�test_string_literals�s$"..zTokenTests.test_string_literalscCs$d}|�|tu�|�ttd�dS)N.z.. .)rG�EllipsisrCrDrEr/r2r2r3�
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)rCrDrs�assertIn�str�	exception)r0�samplesrJ�cmr2r2r3�test_eof_error$s��zTokenTests.test_eof_errorN)�__name__�
__module__�__qualname__�test.supportrr4rKrLrMrUr^rnr�r�r�r�r2r2r2r3r+hs
$
(r+�var_annot_globalc@�$eZdZdd�Zdd�Zdd�ZdS)�CNScC�
i|_dS�N��_dctrTr2r2r3�__init__0�
zCNS.__init__cCs||j|��<dSr�)r��lower�r0�item�valuer2r2r3�__setitem__2szCNS.__setitem__cC�
|j|Sr�r��r0r�r2r2r3�__getitem__4r�zCNS.__getitem__N�r�r�r�r�r�r�r2r2r2r3r�/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)rEr/r2r2r3�test_eval_inputG�zGrammarTests.test_eval_inputcCs@d}dg}dd�}ttgdd||�d<|�|dg�dS)N��*cS�dS�NrOr2r2r2r2r3�oneP�z/GrammarTests.test_var_annot_basics.<locals>.onerrO)�int�listr.)r0�var1�my_lstr�r2r2r3�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
rrTr2r2r3�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)NrOrcSsd}dt_|S)N�Hello�rOr,��a�b)�str2r2r3�ftsz6GrammarTests.test_var_annot_basic_semantics.<locals>.fcS�dSr�r2r2r2r2r3�f_OKy�z9GrammarTests.test_var_annot_basic_semantics.<locals>.f_OKcSst|�dSr���print�r1r2r2r3�fbad|r�z9GrammarTests.test_var_annot_basic_semantics.<locals>.fbadcSstt�dSr�)r��no_such_globalr2r2r2r3�f2bad�r�z:GrammarTests.test_var_annot_basic_semantics.<locals>.f2badc@s.eZdZUeed<dZeed<dZdd�ZdS)z6GrammarTests.test_var_annot_basic_semantics.<locals>.C�_C__foo�attrrJr,cSs
||_dSr�r�r/r2r2r3r��r�z?GrammarTests.test_var_annot_basic_semantics.<locals>.C.__init__N)	r�r�r�r��__annotations__rJr��zr�r2r2r2r3�C�s

r�)r�rJc@seZdZUde_edS)z9GrammarTests.test_var_annot_basic_semantics.<locals>.CBadrN)r�r�r��no_such_name_definedr�r�r2r2r2r3�CBad�s
r�c@s eZdZUeed<ge_edS)z:GrammarTests.test_var_annot_basic_semantics.<locals>.Cbad2r1N)r�r�r�r�r�r1r�r�r2r2r2r3�Cbad2�s
r�)
rC�ZeroDivisionError�no_name�does_not_existr\r.r��UnboundLocalError�	Exception�assertIsrBr�r�)	r0r�r�r�r��er�r�r�r2r2r3�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�r2r2r2r3�A��
r�c@�eZdZdS)z4GrammarTests.test_annotations_inheritance.<locals>.BN�r�r�r�r2r2r2r3�B��r�c@r�)z4GrammarTests.test_annotations_inheritance.<locals>.Cr�N)r�r�r�r�r�r2r2r2r3r��r�r�c@r�)z4GrammarTests.test_annotations_inheritance.<locals>.D�attr2Nr�r2r2r2r3�D�r�r�c@r�)z4GrammarTests.test_annotations_inheritance.<locals>.ENr�r2r2r2r3�E�r�r�c@r�)z4GrammarTests.test_annotations_inheritance.<locals>.FNr�r2r2r2r3�F�r�r�r�r�)r.r�r�r�)r0r�r�r�r�r�r�r2r2r3�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�kwdsr2r2r3�__prepare__��
zJGrammarTests.test_var_annot_metaclass_semantics.<locals>.CMeta.__prepare__N)r�r�r��classmethodr�r2r2r2r3�CMeta�sr�c@seZdZUded<dS)z;GrammarTests.test_var_annot_metaclass_semantics.<locals>.CC�ANNOT�XXN)r�r�r�r�r2r2r2r3�CC�r�r�)�	metaclass�xxr�)rBr.r�)r0r�r�r2r2r3�"test_var_annot_metaclass_semantics�sz/GrammarTests.test_var_annot_metaclass_semanticsc	Cs^|�tji�|�tjdtttjttfttBd��|�tj	jdt
d��|�tji�dS)Nr,)rOr1r�r��u�{)�123�o)r.rur��
ann_moduler�r��typing�Tuple�float�MrBr	rTr2r2r3�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_module3r�)r�import_fresh_modulerCr\�	f_bad_ann�	g_bad_ann�	D_bad_ann)r0�ann_module3r2r2r3�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,)rOr1)r�r.r�rC�KeyError)r0�gns�lnsr2r2r3�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 = 1jr1r�rwcs(eZdZdd�Z�fdd�Zdd�ZdS)z5GrammarTests.test_var_annot_custom_maps.<locals>.CNS2cSr�r�r�rTr2r2r3r��r�z>GrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__init__c�||j|<|�|<dSr�r�r���	nonloc_nsr2r3r���
zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__setitem__cSr�r�r�r�r2r2r3r��r�zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__getitem__Nr�r2rr2r3�CNS2�srz
x: int = 1)r�r�r.r�r�rCr)r0�nsrr2rr3�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�r�rT)�cnsr2r3r���z:GrammarTests.test_var_annot_refleak.<locals>.CNS2.__init__crr�r�r�rr2r3r��rz=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__setitem__cSr�r�r�r�r2r2r3r��r�z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__getitem__Nr�r2�rrr2r3r�srzX: strr1)r�r�r.r�)r0rr2rr3�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, 2r1r�zdef f():
    x: int = yieldr�rO�r,��r�)r�r��crzx: Tuple[int, ...] = a,*b,c�rOr,rrr�)r�r.r�rr)r0r�stmtr2r2r3�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�r�r2r2r2r2r3�f1r�z%GrammarTests.test_funcdef.<locals>.f1r2cSr�r�r2��one_argumentr2r2r3�f2r�z%GrammarTests.test_funcdef.<locals>.f2cSr�r�r2��two�	argumentsr2r2r3�f3r�z%GrammarTests.test_funcdef.<locals>.f3r#r&cSr�r�r2)�one_argr2r2r3�a1r�z%GrammarTests.test_funcdef.<locals>.a1cSr�r�r2)r'�argsr2r2r3�a2r�z%GrammarTests.test_funcdef.<locals>.a2cWr�r�r2��restr2r2r3�v0r�z%GrammarTests.test_funcdef.<locals>.v0cWr�r�r2�r�r/r2r2r3�v1r�z%GrammarTests.test_funcdef.<locals>.v1cWr�r�r2�r�r�r/r2r2r3�v2 r�z%GrammarTests.test_funcdef.<locals>.v2rOr,rrr����r6rcSr�r�r2�r�r2r2r3�d016r�z&GrammarTests.test_funcdef.<locals>.d01�rOr�cSr�r�r2r�r2r2r3�d11>r�z&GrammarTests.test_funcdef.<locals>.d11r�cSr�r�r2�r�r�rr2r2r3�d21Br�z&GrammarTests.test_funcdef.<locals>.d21�rOr,r�r,r�rrcSr�r�r2r�r2r2r3�d02Ir�z&GrammarTests.test_funcdef.<locals>.d02r��r,r�cSr�r�r2r<r2r2r3�d12Qr�z&GrammarTests.test_funcdef.<locals>.d12cSr�r�r2�r�r�r�dr2r2r3�d22Ur�z&GrammarTests.test_funcdef.<locals>.d22cWr�r�r2r1r2r2r3�d01vYr�z'GrammarTests.test_funcdef.<locals>.d01v)rOr,rrcWr�r�r2r3r2r2r3�d11v`r�z'GrammarTests.test_funcdef.<locals>.d11vcWr�r�r2�r�r�rr/r2r2r3�d21vdr�z'GrammarTests.test_funcdef.<locals>.d21vcWr�r�r2r3r2r2r3�d02vjr�z'GrammarTests.test_funcdef.<locals>.d02vrcWr�r�r2rIr2r2r3�d12vqr�z'GrammarTests.test_funcdef.<locals>.d12v�rrr�cWr�r�r2)r�r�rrEr/r2r2r3�d22vyr�z'GrammarTests.test_funcdef.<locals>.d22vrErNr1sfooz/Bytes should not work as keyword argument namescS�|Sr�r2��keyr2r2r3�pos0key1�r�z+GrammarTests.test_funcdef.<locals>.pos0key1�drP)�k2cSs||||fSr�r2)�p1�p2�k1rTr2r2r3�pos2key2��z+GrammarTests.test_funcdef.<locals>.pos2key2)rW��)rWrT)rTrWc[s|||||fSr�r2)rUrVrWrT�kwargr2r2r3�pos2key2dict��z/GrammarTests.test_funcdef.<locals>.pos2key2dict)rT�tokwarg1�tokwarg2)r^r_rTzdef f(*): passzdef f(*,): passzdef f(*, **kwds): passc_s||fSr�r2)r,�kwargsr2r2r3r��sz$GrammarTests.test_funcdef.<locals>.f�r1r�)rOrrzf(1, x=2, *(3,4), x=5)�	scrambled�fried)�eggsr�r�rdz
f(*g(1=2))zf(**g(1=2))�returncSr�r�r2r�r2r2r3r��r�cSr�r�r2r�r2r2r3r��r�cSr�r�r2r�r2r2r3r��r�r�cSr�r�r2r�r2r2r3r��r�cWr�r�r2r�r2r2r3r��r�c[r�r�r2r�r2r2r3r��r�r�cSr�r�r2rar2r2r3r��r�cSr�r�r2rar2r2r3r��r�cSr�r�r2rDr2r2r3r��r�)r�rcSr�r�r2rDr2r2r3r��r�r��gcWr�r�r2)r�r�rrEr�r�rfr2r2r3r��r�)r�rr�rf�
��i�j�hrj�k��c_r�r�r2�r�r�rrEr�r�rkrirjrfrlr2r2r3r��r�)r�rr�rfrkrjrlrer�c_r�r�r2ror2r2r3r��r�)	r�rr�r�rfrkrjrlrec@seZdZddd�ZdS)z'GrammarTests.test_funcdef.<locals>.Spam�	_Spam__kwrOcSr�r�r2)r0rpr2r2r3r��r�z)GrammarTests.test_funcdef.<locals>.Spam.fN)rprO)r�r�r�r�r2r2r2r3�Spam�srqc@r�)z&GrammarTests.test_funcdef.<locals>.HamNr�r2r2r2r3�Ham�rYrrrpcSrOr�r2r�r2r2r3�null�r�z'GrammarTests.test_funcdef.<locals>.nullcSr�r�r2r�r2r2r3r��r�FcSr�r�r2r�r2r2r3r��r�cSr�r�r2r�r2r2r3r��r�c��|�Sr�r2�r�)rsr2r3�<lambda>��z+GrammarTests.test_funcdef.<locals>.<lambda>cSr�r�r2r�r2r2r3r��r�.cSr�r�r2r�r2r2r3r��r�cSr�r�r2r�r2r2r3r��r�cSr�r�r2r�r2r2r3r��r�c��Sr�r2r2��closurer2r3r��r�crxr�r2r�ryr2r3r��r��rlcrxr�r2r{ryr2r3r��r�crxr�r2r2ryr2r3r��r�cSr�r�r2r8r2r2r3r��r�cWr�r�r2�r,r2r2r3r��r�c[r�r�r2�r�r2r2r3r��r�cWr�r�r2�r�r,r2r2r3r��r�c[r�r�r2�r�r�r2r2r3r��r�cWr�r�r2�r�r,r2r2r3r��r�cSr�r�r2�r�r2r2r3r��r�c_r�r�r2�r,r�r2r2r3r��r�cWr�r�r2�r�r�r,r2r2r3r��r�cSr�r�r2r�r2r2r3r��r�c_r�r�r2�r�r,r�r2r2r3r��r�c_r�r�r2�r�r,r�r2r2r3r��r�c[r�r�r2�r�r�r2r2r3r��r�c_r�r�r2�r�r�r,r�r2r2r3r��r�c[r�r�r2�r�r�r�r2r2r3r��r�r�)r�)r�r)r�rOrr,)rr,r�rO)rr�)r�rOrr,r�rrfr5)r�rOrr,r�rrfr5rkr6rjr6rlrmrern)r.�__code__�co_varnamesrPrQrR�BytesWarningr��	TypeErrorrIrCrDrErr�r�r�rr��__call__)r0r"r%r)r+r-r0r2r4r9r;r=rArCrFrGrHrJrKrLrNrRrXr\r�rqrrrEr2)rzrsr3�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))NcSr��Nrr2r2r2r2r3rvr�z+GrammarTests.test_lambdef.<locals>.<lambda>rcSsttSr�)r�rEr2r2r2r3rvrwcSsdd�dD�S)NcSsg|]}d|k�qSrBr2��.0r1r2r2r3�
<listcomp>�z?GrammarTests.test_lambdef.<locals>.<lambda>.<locals>.<listcomp>)���rrr2r2r2r2r3rvr])rrOrrOcSrOr�r2�r�r2r2r3rvr�cS�|�Sr�r2)r�r2r2r3rv�cSr�r�r2r�r2r2r3rvr�r,cS�|||Sr�r2)r1r�r�r2r2r3rvrYr�rr5zlambda x: x = 2zlambda (None,): None�r{cSr�r�r2)r1r�rlr2r2r3rv
rY�rg�
cSr�r�r2r8r2r2r3rvr�cWr�r�r2r|r2r2r3rvr�c[r�r�r2r}r2r2r3rvr�cWr�r�r2r~r2r2r3rvr�c[r�r�r2rr2r2r3rvr�cWr�r�r2r�r2r2r3rvr�cSr�r�r2r�r2r2r3rvr�c_r�r�r2r�r2r2r3rvr�cWr�r�r2r�r2r2r3rvr�cSr�r�r2r�r2r2r3rvr�c_r�r�r2r�r2r2r3rvr�c_r�r�r2r�r2r2r3rvr�c[r�r�r2r�r2r2r3rvr�c_r�r�r2r�r2r2r3rvr�c[r�r�r2r�r2r2r3rv r�r:rB�r.r)r0�l1�l2�l3�l4�l5�l6�l10�l11�l12�l13�l14�l15�l16�l17�l18�l19�l20�l21�l22�l23�l24r2r2r3�test_lambdef�s<


zGrammarTests.test_lambdefcCsd}~dd�}|�dS)NrOcSs
d}~dSr�r2r�r2r2r3�foo)r�z*GrammarTests.test_simple_stmt.<locals>.foor2)r0r1r�r2r2r3�test_simple_stmt&s
zGrammarTests.test_simple_stmtc	CsV		d}d}d}}}d\}}}d}\}}}\}}}}t|d�t|d�dS)NrOr>)rOr,)rrz	x + 1 = 1z
a + 1 = b + 2r)	r0r1r�r��abcr�r�r�xyzr2r2r3�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�r�)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)�formatrr�assertRaisesRegexrDr�rZ)r0�keywords�cases�keyword�
custom_msg�caser�r2r2r3�(test_former_statements_refer_to_builtins@s,


���
������z5GrammarTests.test_former_statements_refer_to_builtinscCs�gd�}|\}}}|||f}~~~~~d\}}}~~~d\}}}}	}
}}~~~~	~
~d\}}}}	}
}}~~~~	~
~td�}
|
dd�=tddd	�dS)
Nr>r��abcdefg�abcdrOr,z-del a, (b[0].c, (d.e, f.g[1:2])), [h.i.j], ()rqr�)r�rs)r0r�r1r�r�r�r�r�rrEr�r�rfr�r2r2r3�
test_del_stmtWs 



zGrammarTests.test_del_stmtcCr�r�r2rTr2r2r3�test_pass_stmtq�zGrammarTests.test_pass_stmtcCr�r�r2rTr2r2r3�test_break_stmtxr�zGrammarTests.test_break_stmtcCsxd}|rd}qd}|sd}zWq	d}Y|r|dkr!|�|�d}|s/d}zWd}q#d}w|dkr:|�|�dSdS)NrOrrW�okz&continue failed to continue inside tryz'continue inside try called except blockzfinally block not called�rI)r0ri�msgr2r2r3�test_continue_stmt|s*
�
�zGrammarTests.test_continue_stmtcsd�fdd�	}|�dS)NrOrcs`d}|r|d7}z|r|dkr|d8}Wn
|d8}Wq�|dks'|dkr.��d�dSdS)Nr,rOz1continue then break in try/except in loop broken!r�)�extra_burning_oil�count�	big_hipporTr2r3�
test_inner�s�z9GrammarTests.test_break_continue_loop.<locals>.test_inner)rOrr2)r0r�r2rTr3�test_break_continue_loop�s

z%GrammarTests.test_break_continue_loopcCsFdd�}dd�}dd�}|�|�}|�}|�|dd�t|d	�dS)
NcSr�r�r2r2r2r2r3�g1�r�z$GrammarTests.test_return.<locals>.g1cSr�r�r2r2r2r2r3�g2�r�z$GrammarTests.test_return.<locals>.g2cSsddg}dg|�RS)Nr,rrOr2r�r2r2r3�g3�sz$GrammarTests.test_return.<locals>.g3r>z unparenthesized star expr returnzclass foo:return 1r�)r0r�r�r�r1r�r2r2r3�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,rO�rrOr-�r0r�r2r2r3�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�dSr�r-r�r2r2r3�test_continue_in_finally�sH

z%GrammarTests.test_continue_in_finallycCsFdd�}|�|�d�dd�}|�|�d�dd�}|�|�d	�dS)
NcS�zWdSYdSr�r2r2r2r2r3r�(�z/GrammarTests.test_return_in_finally.<locals>.g1rOcSr�)Nrr2r2r2r2r3r�/r�z/GrammarTests.test_return_in_finally.<locals>.g2rcSszddWdSYdS)NrOrrr2r2r2r2r3r�6s
z/GrammarTests.test_return_in_finally.<locals>.g3rr-)r0r�r�r�r2r2r3�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)Nr�rr�rg�endr2�r1r��count2r2r2r3r�?s
��
z;GrammarTests.test_break_in_finally_after_return.<locals>.g1FrgT)r�rOrgc	SsLdD]}dD]}z||W|rnS|rYnwqd||fS)Nr�)rgr�r�r2r�r2r2r3r�Ms��
z;GrammarTests.test_break_in_finally_after_return.<locals>.g2r-�r0r�r�r2r2r3�"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)NrrSrOr�r2�r1r�r2r2r3r�[s�z>GrammarTests.test_continue_in_finally_after_return.<locals>.g1FrOT)r�rScSs4dD]}z	|W|rqS|rYqwd|fS)Nr�r�r2r�r2r2r3r�hs
�z>GrammarTests.test_continue_in_finally_after_return.<locals>.g2r)r�rOr-r�r2r2r3�%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��dVdSr�r2r2r2r2r3rfu��
z"GrammarTests.test_yield.<locals>.gcss�dEdHdS�Nr2r2r2r2r2r3rfv��cs��dV}dSr�r2r�r2r2r3rfxr�css�dEdH}dSr�r2r�r2r2r3rfyr�csr��N)rOrOr2r2r2r2r3rf{r�csr�r�r2r�r2r2r3rf|r�zdef g(): yield from (), 1zdef g(): x = yield from (), 1css�ddVfdSr�r2r2r2r2r3rf�r�css�ddEdHfdS�NrOr2r2r2r2r2r3rf���zdef g(): 1, yield 1zdef g(): 1, yield from ()css�tdV�dSr�rur2r2r2r3rf�r�css�tdVd�dSr�rur2r2r2r3rf�s�css�tdEdH�dSr�rur2r2r2r3rf�r�css�tdEdHd�dS)Nr2rOrur2r2r2r3rf���css�d}dddg|�RVdS)N�rr�r5rOr,rr2r.r2r2r3rf���)rOr,rrr�r5zdef 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)rr.r��r0rfr2r2r3�
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|]}|�qSr2r2r�r2r2r3r����HGrammarTests.test_yield_in_comprehensions.<locals>.g.<locals>.<listcomp>rOr2r2r2r2r3rf���z4GrammarTests.test_yield_in_comprehensions.<locals>.gcss�dd�dEdHfD�dS)NcSr�r2r2r�r2r2r3r��r�r�r2r2r2r2r2r3rf�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)r0rfrmr2r2r3�test_yield_in_comprehensions�sB����������z)GrammarTests.test_yield_in_comprehensionscCs6ztd��ty
Ynwzt�tyYdSw)Nzjust testing)�RuntimeError�KeyboardInterruptrTr2r2r3�
test_raise�s
zGrammarTests.test_raisecCsdddl}ddl}ddl}ddlm}ddlm}ddlm}m}ddlm}m}ddlm}m}dS)Nr)�time)�path�argv)rFr�r�r�)r0rFr�r�r�r2r2r3�test_import�szGrammarTests.test_importcCr�r�r2rTr2r2r3�test_global�r�zGrammarTests.test_globalcsd�d���fdd�}dS)Nrcr�r�r2r2rar2r3r��r�z%GrammarTests.test_nonlocal.<locals>.fr2)r0r�r2rar3�
test_nonlocal�szGrammarTests.test_nonlocalc
Cs�		dd�sJ�	z	Wnty#}z|�d�WYd}~nd}~wwzWdSty?}z|�d�WYd}~dSd}~ww)	NrOcSrOr�r2r�r2r2r3rv�r�z*GrammarTests.test_assert.<locals>.<lambda>cSs|dSr�r2r�r2r2r3rv�rwTz6'assert True' should not have raised an AssertionErrorzthis should always passz;'assert True, msg' should not have raised an AssertionError)�AssertionErrorrI�r0r�r2r2r3�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)Nrr�)r�r.r,rIr�rr2r2r3�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"rqr�zassert False, "msg")rr�r�rsrTr2r2r3�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)	Nrvzassert x, "msg" rqr�z4SyntaxError incorrectly raised for 'assert x, "msg"'rrr)rPrQrRr�rsrDrIrCrTr2r2r3�,test_assert_warning_promotes_to_syntax_errors&
�����
"�z9GrammarTests.test_assert_warning_promotes_to_syntax_errorcCs									dSr�r2rTr2r2r3�test_ifszGrammarTests.test_ifcCs 			d}	d}|�|d�dS)NrrOr,r-r/r2r2r3�
test_while*szGrammarTests.test_whilecCs�dD]}qdD]\}}}q	Gdd�d�}d}|d�D]}||}q|dkr+|�d�g}d	D]\}|�|�q/|�|gd��dS)
Nr>r2c@r�)z&GrammarTests.test_for.<locals>.SquarescSs||_g|_dSr�)�max�sofar)r0rr2r2r3r�?s
z/GrammarTests.test_for.<locals>.Squares.__init__cSs
t|j�Sr�)r�rrTr2r2r3�__len__Bs
z.GrammarTests.test_for.<locals>.Squares.__len__cSsZd|kr|jkst�t�t|j�}||kr(|j�||�|d}||ks|j|S)NrrO)r�
IndexErrorr�r�append)r0ri�nr2r2r3r�Cs
�
z2GrammarTests.test_for.<locals>.Squares.__getitem__N)r�r�r�r�r
r�r2r2r2r3�Squares>srrrgizfor over growing sequence)r:rBr@)rIrr.)r0rirjrlrrr1�resultr2r2r3�test_for9s


zGrammarTests.test_forc
CszddWn	tyYnw	zddWnty Ynty1}zWYd}~n
d}~wYn	zddWntttfyIYnwzddWntttfye}zWYd}~nd}~wwzWnw|�t��tddd�tddd�Wd�dS1s�wYdS)NrOrz/try:
    pass
except Exception as a.b:
    pass�?r�z0try:
    pass
except Exception as a[b]:
    pass)r��EOFErrorr�rCrDrs)r0r�r2r2r3�test_tryTs0��
 �"�zGrammarTests.test_trycCs							dSr�r2rTr2r2r3�
test_suitemszGrammarTests.test_suitecCs						dSr�r2rTr2r2r3�	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�r2r/r2r2r3�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)Nrcs��||�dSr�r)rur�rTr2r3rm��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 literalrvz	x is Nonerqr�z
x is Falsez	x is Truezx is ...)r�rPrQrRr�rsrlr2rTr3�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��|��dSr�r)ru�r�r0r2r3rm�rz2GrammarTests.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] [...]]rvz[(lambda x, y: x) (3, 4)]rqr�z[[1, 2] [i]]z[[1, 2] [0]]z[[1, 2] [True]]z[[1, 2] [1:2]]z[{(1, 2): 3} [i, j]]rrlr2rr3�test_warn_missed_comma�s�
$�z#GrammarTests.test_warn_missed_commacCsd}d}d}dS)NrOrr2r/r2r2r3�test_binary_mask_ops��z!GrammarTests.test_binary_mask_opscCsd}d}d}dS)Nr,rrOr2r/r2r2r3�test_shift_opsr zGrammarTests.test_shift_opscCsd}d}d}d}dS)NrOr,r�r2r/r2r2r3�test_additive_ops�zGrammarTests.test_additive_opscCsd}d}d}d}dS)NrO��?rgr2r/r2r2r3�test_multiplicative_opsr#z$GrammarTests.test_multiplicative_opscCsd}d}d}d}d}dS)NrOr����r$r2r/r2r2r3�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��01234r�r����������rOr,r:rr�rr>cSst|�j|fSr�)rBr�r�r2r2r3rv3r]z-GrammarTests.test_selectors.<locals>.<lambda>rPz[1, (1,), (1, 2), (1, 2, 3)])rFr�r��modulesr��sortr.r�)	r0rFr�rr1r�rJrE�Lr2r2r3�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)NrOr,rr�r')r�r'rr�r5)r�r'�three�four�five�six>r�r'r0>r,rrr1r�r2r/r2r2r3�
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�r2r2r2r3r�[rYr�c@r�)z&GrammarTests.test_classdef.<locals>.B2Nr�r2r2r2r3�B2\rYr5c@r�)z&GrammarTests.test_classdef.<locals>.C1Nr�r2r2r2r3�C1]rYr6c@r�)z&GrammarTests.test_classdef.<locals>.C2Nr�r2r2r2r3�C2^rYr7c@r�)z%GrammarTests.test_classdef.<locals>.DNr�r2r2r2r3r�_rYr�c@r�)z%GrammarTests.test_classdef.<locals>.CcSr�r�r2rTr2r2r3�meth1ar�z+GrammarTests.test_classdef.<locals>.C.meth1cSr�r�r2)r0�argr2r2r3�meth2br�z+GrammarTests.test_classdef.<locals>.C.meth2cSr�r�r2)r0r+r-r2r2r3�meth3cr�z+GrammarTests.test_classdef.<locals>.C.meth3N)r�r�r�r8r:r;r2r2r2r3r�`sr�cSrOr�r2r�r2r2r3�class_decoratorhr�z3GrammarTests.test_classdef.<locals>.class_decoratorc@r�)z%GrammarTests.test_classdef.<locals>.GNr�r2r2r2r3�Gir�r=Fc@r�)z%GrammarTests.test_classdef.<locals>.HNr�r2r2r2r3�Hmr�r>c@r�)z%GrammarTests.test_classdef.<locals>.INr�r2r2r2r3�Ior�r?crtr�r2)r�r<r2r3rvqrwz,GrammarTests.test_classdef.<locals>.<lambda>c@r�)z%GrammarTests.test_classdef.<locals>.JNr�r2r2r2r3�Jqr�rA.rOc@r�)z%GrammarTests.test_classdef.<locals>.KNr�r2r2r2r3�Ksr�rBc@r�)z%GrammarTests.test_classdef.<locals>.LNr�r2r2r2r3r.ur�r.rc@r�)z%GrammarTests.test_classdef.<locals>.MNr�r2r2r2r3rwr�r)r�)r0r�r5r6r7r�r�r=r>rEr?rArBr.rr2r@r3�
test_classdefYs*

zGrammarTests.test_classdefcCs*gd�}|�dd�|D�dddd��dS)Nr>cSsi|]}||d�qSr:r2�r�rir2r2r3�
<dictcomp>sz/GrammarTests.test_dictcomps.<locals>.<dictcomp>r,rrr-)r0�numsr2r2r3�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|]}|���qSr2)�strip)r�rJr2r2r3r��r�z/GrammarTests.test_listcomps.<locals>.<listcomp>)rHrIz	Coco  nutcSsg|]}d|�qSr@r2r�r2r2r3r��r�)rr5r6rn�cSsg|]}|dkr|�qSrBr2r�r2r2r3r���rMcsg|]}�D]}||f�qqSr2r2�r�rirJ��strsr2r3r���))rOrH�rOrI�rOrJ)r,rH�r,rI�r,rJ)rrH�rrI�rrJ)rrH�rrI�rrJ)r�rH�r�rI�r�rJcs(g|]}dd��D�D]}||f�qqS)cSsg|]}d|vr|�qS)rr2)r�r�r2r2r3r��rMz:GrammarTests.test_listcomps.<locals>.<listcomp>.<listcomp>r2rNrOr2r3r��s()
rRrSrTrUrVrWrXrYrZr[cSsg|]}dd�|��qS)cs�fdd�t�d�D�S)Ncsg|]}�|�qSr2r2rDr8r2r3r��r�zLGrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>.<locals>.<listcomp>rO��ranger8r2r8r3rv�sz8GrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>r2)r�rjr2r2r3r��rMr�rO)rOr,r)rOrr6�)rOr��@�cSsdd�|D�S)NcSs,g|]}|dkrd|kodkn�qS)r,rrr2r�r2r2r3r��s,zEGrammarTests.test_listcomps.<locals>.test_in_func.<locals>.<listcomp>r2)�lr2r2r3�test_in_func�rz1GrammarTests.test_listcomps.<locals>.test_in_func)FFFcs,��dd�dD�ddgddgdd	gg�dS)
NcSs"g|]
}dd�||dfD��qS)cSr�r2r2�r�r�r2r2r3r��r�zUGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>.<listcomp>rOr2r�r2r2r3r���"zJGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>)rOrr�rOr,rrr�r5r-r2rTr2r3�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]))rO�Boeing)r,�Ford)r�
Macdonalds))rg�Airliner)r��Engine)��Cheeseburger))rOrg)rOr�)r,r�)rrlcsDg|]\}}�D]\}}�D]\}}||kr||kr||f�qqqSr2r2)r��sno�sname�pno�pname�sp_sno�sp_pno)�parts�suppartr2r3r��s���
))rgrj)rgrk)rhrk)rirm)r.r]r)r0rF�spcsrcrf�	suppliersr1r2)rtr0rPrur3�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�r2r2r�r2r2r3r��r�z7GrammarTests.test_genexps.<locals>.<genexpr>.<listcomp>rgNr\r�r2r2r3�	<genexpr>��� z,GrammarTests.test_genexps.<locals>.<genexpr>rOcSr�r2r2r�r2r2r3r��r�z-GrammarTests.test_genexps.<locals>.<listcomp>rgz&should produce StopIteration exceptionc3s�|]}�VqdSr�r2)r�rEr8r2r3ry�r�zshould produce TypeErrorcs�"�|]}dD]}||fVqqdS)r�Nr2�r�r1r�r2r2r3ry�rzr�cS�g|]}dD]}||f�qqS)r�r2r|r2r2r3r��rQcsr{)�xyNr2r|r2r2r3ry�rz�abcSr})r~r2r|r2r2r3r��rQcSr�r2r2r�r2r2r3r��r�cs��|]}|VqdSr�r2r�r2r2r3ry�r�csr�r�r2rdr2r2r3ry�r�cSr�r2r2r�r2r2r3r��r�css�|]}|dVqdS�r,Nr2r�r2r2r3ry�r�cSsg|]}|d�qSrBr2r�r2r2r3r��r�css �|]}|dr||VqdSr�r2r�r2r2r3ry�s�cSsg|]
}|dr||�qSrBr2r�r2r2r3r���csr�r�r2r�r2r2r3ry�r�csr�r�r2rdr2r2r3ry�r�cSr�r2r2r�r2r2r3r��r�csr�r�r2r�r2r2r3ry�r�csr�r�r2rdr2r2r3ry�r�csr�r�r2�r�r�r2r2r3ry�r�cSr�r2r2r�r2r2r3r��r�csr�r�r2r�r2r2r3ry�r�cSr�r2r2rdr2r2r3r��r�csr�r�r2r�r2r2r3ry�r�cSr�r2r2r�r2r2r3r��r�cs��|]}|VqdS�TNr2r�r2r2r3ry�r�csr�r�r2rdr2r2r3ry�r�csr�r�r2r�r2r2r3ry�r�cSr�r2r2r�r2r2r3r��r�csr�r�r2r�r2r2r3ry�r�css�|]}qdS)FNr2rdr2r2r3ry�s�csr�r�r2r�r2r2r3ry�r�rzfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r]r.�nextrI�
StopIterationr�r��sumr)r0rfr�r2r8r3�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)Nrgcsr�r�r2rDr2r2r3ry�r�z;GrammarTests.test_comprehension_specials.<locals>.<genexpr>r�Fc3s*�|]}�rt��D]}||fVq
qdSr�r\�r�rirj��tr1r2r3ry�s�(TcSs"g|]
}td�D]}||f�qqS�r�r\r�r2r2r3r��rez<GrammarTests.test_comprehension_specials.<locals>.<listcomp>cSs g|]}|dr|dr|�qSr?r2r�r2r2r3r��s )rOr�r6css$�|]
}|dr|dr|VqdS)r,rNr2r�r2r2r3ry�s�"cSsg|]\}|�qSr2r2r�r2r2r3r��s))rr�)r5r�css�|]\}|VqdSr�r2r�r2r2r3ry�r�))r6)r7)r6)r6r7r6)r]r.r�r�r�r2r�r3�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>.managercSr��Nr�r2rTr2r2r3�	__enter__�r�z;GrammarTests.test_with_statement.<locals>.manager.__enter__cWr�r�r2)r0r,r2r2r3�__exit__�r�z:GrammarTests.test_with_statement.<locals>.manager.__exit__N)r�r�r�r�r�r2r2r2r3�manager��r�)�object)r0r�r1r�r�r2r2r3�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|�|S)z@helper to check that evaluation of expressions is done correctlyr�)r��retr2r2r3�
_checkeval<sz2GrammarTests.test_if_else_expr.<locals>._checkevalcSsg|]}|�r|��qSr2r2r�r2r2r3r�CrMz2GrammarTests.test_if_else_expr.<locals>.<listcomp>cSr�)NTr2r2r2r2r3rvCr�z0GrammarTests.test_if_else_expr.<locals>.<lambda>cSr��NFr2r2r2r2r3rvCr�TcSsg|]
}|d�r|d��qSr�r2r�r2r2r3r�Dr�cS�|rdSdS)NFTr2r�r2r2r3rvDrYcSr�)NTFr2r�r2r2r3rvDrYrOr�zcheck 1rzcheck 2r5zcheck 3r,rzcheck 4zcheck 5zcheck 6Fr6rnrg@r-)r0r�r2r2r3�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)Nr7r,rF)r.rG�assertFalser�r2r2r3�test_paren_evaluationUs(z"GrammarTests.test_paren_evaluationcCs>Gdd�d�}|�}|�||d�|d}|�|jd�dS)Nc@r�)z'GrammarTests.test_matrix_mul.<locals>.McSr�)Nrr2�r0r�r2r2r3�
__matmul__cr�z2GrammarTests.test_matrix_mul.<locals>.M.__matmul__cSs
||_|Sr�)�otherr�r2r2r3�__imatmul__esz3GrammarTests.test_matrix_mul.<locals>.M.__imatmul__N)r�r�r�r�r�r2r2r2r3rbr�rrr�)r.r�)r0r�mr2r2r3�test_matrix_mul_s
zGrammarTests.test_matrix_mulcCsxdd�}|�|jd�|�t|jjtj@��dd�}|dd��}|�|j�|�|jd�|�t|jjtj@��dS)	Nc�s�dd�}	t�IdHdS)NcSr�r�r2r2r2r2r3r�or�z8GrammarTests.test_async_await.<locals>.test.<locals>.sum)�someobj)r�r2r2r3runs�z+GrammarTests.test_async_await.<locals>.testrucSst|dd�|S)N�_markedT)�setattr)�funcr2r2r3�	decoratorwsz0GrammarTests.test_async_await.<locals>.decoratorc���dS)N�r2r2r2r2r3�test2{s�z,GrammarTests.test_async_await.<locals>.test2r�)	r.r�rG�boolr��co_flags�inspect�CO_COROUTINEr�)r0rur�r�r2r2r3�test_async_awaitms
zGrammarTests.test_async_awaitcshGdd�dt��Gdd�d����fdd�}|����|��d�Wd�dS1s-wYdS)Nc@r�)z)GrammarTests.test_async_for.<locals>.DoneNr�r2r2r2r3�Done�rYr�c@r�)z*GrammarTests.test_async_for.<locals>.AItercSrOr�r2rTr2r2r3�	__aiter__�r�z4GrammarTests.test_async_for.<locals>.AIter.__aiter__c�s�t�r�)�StopAsyncIterationrTr2r2r3�	__anext__���z4GrammarTests.test_async_for.<locals>.AIter.__anext__N)r�r�r�r�r�r2r2r2r3�AIter�r�r�c�sN���2z3dHW}q6��2z3dHW\}}q6��2z3dHW}q6	��r�r2rh�r�r�r2r3r��s����z(GrammarTests.test_async_for.<locals>.foo�r�rC�send�r0r�r2r�r3�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�r2r2r2r3r��rYr�c@r�)z-GrammarTests.test_async_with.<locals>.managerc�r�r�r2rTr2r2r3�
__aenter__�r�z8GrammarTests.test_async_with.<locals>.manager.__aenter__c�r�r�r2)r0�excr2r2r3�	__aexit__�r�z7GrammarTests.test_async_with.<locals>.manager.__aexit__N)r�r�r�r�r�r2r2r2r3r��r�r�c
�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��r�r2ra�r�r�r2r3r��s,�(�(�(� R� R� :��z)GrammarTests.test_async_with.<locals>.foor�r�r2r�r3�test_async_with�s"�zGrammarTests.test_async_withN)Lr�r�r�r�r�test.support.warnings_helperrr�r�r�r�r�r�r�rrrrrr!r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�unittest�
skipUnlessrrrr	r
rrrrrrrrr!r"r%r'r/r4rCrGrxr�r�r�r�r�r�r�r�r�r2r2r2r3r�8s�.		
y'45'



R#!?#D
r��__main__)r�rrr�rr�r�rFrP�test.ann_modulerr�collectionsrrur	rYr[�TestCaser+r�r�r�r�r��mainr2r2r2r3�<module>sH7D	
�

Youez - 2016 - github.com/yon3zu
LinuXploit