
    <e                    6   U d dl mZ d dl mZ d dlmZ d dlZd dlZd dlZd dlZd dlT d dl	m
Z
 d dlZd dlmZ d dlmZ d dlZg dZg d	Z G d
 dej                  Zeed<    G d d          Z G d dej                  Zedk    r ej                     dS dS )    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.5z1_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_z1.4j_0x_0b1_0xf_0o5_z0 if 1_Else 10_b00_xf0_o50_709_99	4_______2z0.1__4z0.1__4j0b1001__01000xffff__ffff0x___0o5__771e1__01e1__0jz1_.4z1_.4jz1._4z1._4jz._5z._5jz1.0e+_1z1.0e+_1jz1.4_jz1.4e5_j1_e1z1.4_e1z1.4_e1j1e_1z1.4e_1z1.4e_1jz
(1+1.5_j_)z	(1+1.5_j)c                   h    e Zd ZddlmZ ddlmZ d Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd ZdS )
TokenTestsr   r   r   c                 j    d}|                      |dd           d}|                      |dd           d S )N   zbackslash for line continuationr   zbackslash ending commentassertEqualselfxs     (/usr/lib/python3.11/test/test_grammar.pytest_backslashzTokenTests.test_backslashm   sH    A@AAA A9:::::    c                 ,   |                      t          d          t          d                     |                      dd           |                      dd           |                      dd           |                      dd           |                     t          t          d           ddlm} |dk    r|                      dd           |                     ddk               |                     ddk               |                     ddk               d	D ]:}	 t	          |          }# t          $ r | 	                    d
|z             Y 7w xY wd S |dk    r|                      dd           |                     ddk               |                     ddk               |                     ddk               dD ]:}	 t	          |          }# t          $ r | 	                    d
|z             Y 7w xY wd S | 	                    d|z             d S )Nr      i	   0x)maxsizei   l    )
21474836480o400000000000x100000000"0b10000000000000000000000000000000z(OverflowError on huge integer literal %rl    l             l    )92233720368547758080o20000000000000000000000x10000000000000000A0b100000000000000000000000000000000000000000000000000000000000000zWeird maxsize value %r)
r1   typeassertRaisesSyntaxErrorevalsysr<   
assertTrueOverflowErrorfail)r3   r<   sr4   s       r5   test_plain_integerszTokenTests.test_plain_integersw   sz   cDGG,,,s###$$$]333###+tT222j  ]N;;;OOMA-...OOJN+++OO=ABBB< N NNQAA$ N N NIIH1LMMMMMN	N N +++35NOOOOO4q8999OO.2333OO\_``aaaY N NNQAA$ N N NIIH1LMMMMMNN N II.899999s$   D,,"EEG"G76G7c                 &    d}d}d}d}d}d}d}d}d S )Nr   rA   l   ? l   
~l!]c l            l    r2   s     r5   test_long_integerszTokenTests.test_long_integers   s.    *SSr7   c                 2    d}d}d}d}d}d}d}d}d}d}d}d S )NgQ	@g     s@gjt?g  Bgt =g  WHBg     F@rQ   r2   s     r5   test_floatszTokenTests.test_floats   s=    r7   c                 ^   t          j                    5  t          j        dt                     |                     t          d          d           |                     t          d          d           d d d            n# 1 swxY w Y   |                     t          t
          d           d S )Nignorez1 if 1else 0   z1 if 0else 0r   z0 if 1Else 0)warningscatch_warningssimplefilterSyntaxWarningr1   rI   rG   rH   r3   s    r5    test_float_exponent_tokenizationz+TokenTests.test_float_exponent_tokenization   s    $&& 	6 	6!(M:::T.111555T.111555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	+t^<<<<<s   A!BBBc           
      :   t           D ]F}|                     t          |          t          |                    dd                               Gt          D ]#}|                     t          t          |           $|                     t          t          d           d S )N_ _0)VALID_UNDERSCORE_LITERALSr1   rI   replaceINVALID_UNDERSCORE_LITERALSrG   rH   	NameError)r3   lits     r5   test_underscore_literalsz#TokenTests.test_underscore_literals   s    , 	D 	DCT#YYS[[b-A-A(B(BCCCC. 	6 	6Ck45555)T400000r7   c                    | j         } |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 S )N0b12z#invalid digit '2' in binary literal0b1_20b2r   zinvalid binary literal0b0o18z"invalid digit '8' in octal literal0o1_80o80o1_zinvalid octal literal0o0x1_zinvalid hexadecimal literalr;   1_zinvalid decimal literal012z`leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integersz1.2_1e2_z1e+r   r3   checks     r5   test_bad_numerical_literalsz&TokenTests.test_bad_numerical_literals   s]   'f;<<<g<===e:;;;f.///d,---f:;;;g;<<<e9:::f-...d+,,,f3444d1222d-...e4	5 	5 	5 	f/000f/000e./////r7   c                 n    d fd	}dD ]}t          |dd            || d|dk                || d	|d
k                || d            || d            || d            |d| d|dk                |d| d            || dd           t          j                    5  t          j        ddt                                          t          d          5  t          | ddd           d d d            n# 1 swxY w Y   t          j        dt                                          t          d          5  t          | ddd           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y    |d            |d            |d           d S )NFc                                         |           5  |rt          j        d          5 }                    t          d          5  t          | dd           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y                       |g            n                    | d           d d d            d S # 1 swxY w Y   d S )N)exprT)recordinvalid \w+ literal
<testcase>rI   )errtext)subTestrX   rY   assertRaisesRegexrH   compiler1   r   )testerrorwr3   s      r5   rw   z8TokenTests.test_end_of_numerical_literals.<locals>.check   s   4(( 	< 	< <!0=== @!33K$:< < @ @#D,???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ $$Q,,,,--d$: . < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<sX   CBA*B*A..B1A.2B5CB	CB		1CCC)0xf0o70b190z1.1e31jr~   rI   zand xr   )r   zor xr   zin xznot in xzif x else yzx if zelse y[zfor x in ()]spamTrV   "is" with a literalr}   zis xr   z[0x1ffor x in ()]z[0x1for x in ()]z[0xfor x in ()]F)	r   rX   rY   filterwarningsr[   assertWarnsRegexrZ   r   rH   )r3   rw   nums   `  r5   test_end_of_numerical_literalsz)TokenTests.test_end_of_numerical_literals   s>   
	< 
	< 
	< 
	< 
	< 
	< D 	@ 	@CCv...ES---u6666ES,,,scz3333ES,,,ES"""###ES%%%&&&E%#%%%cUl<<<<E'c'''(((ES,,,d++++(** 	@ 	@'2G(57 7 7**=24 4 @ @sLLL,???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ %g}===++K24 4 @ @sLLL,???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	!""" !!!     sZ   77F.DFDFD8FE0$F0E44F7E48FF	F	c                    d}d}|                      t          |          dk    o||k               d}d}|                      t          |          dk    o||k    ot          |          dk               d}d}|                      t          |          dk    o||k    ot          |          dk               d}d}|                      t          |          d	k    o||k               d
}d
}|                      t          |          d	k    o||k               d}d}|                     ||           d}|                     ||           d}|                     ||           d}|                     ||           d S )Nr`   r   'rW   '   ""   zdoesn't "shrink" does it   zdoes "shrink" doesn't itz2
The "quick"
brown fox
jumps over
the 'lazy' dog.
)rK   lenordr1   r3   r4   ys      r5   test_string_literalszTokenTests.test_string_literals   s   BA!(>Q???c!4??3q66Q;+R16+Rc!ffPRlSSST4??3q66Q;+R16+Rc!ffPRlSSS('A"/a000('A"/a000 HA 	A 	A 	Ar7   c                     d}|                      |t          u            |                     t          t          d           d S )N.z.. .)rK   EllipsisrG   rH   rI   r2   s     r5   test_ellipsiszTokenTests.test_ellipsis(  s;    X&&&+tV44444r7   c                     d}|D ]m}|                      t                    5 }t          |dd           d d d            n# 1 swxY w Y   |                     dt	          |j                             nd S )N)zdef foo(z	
def foo(z	def foo(
z<test>execzwas never closed)rG   rH   r   assertInstr	exception)r3   samplesrN   cms       r5   test_eof_errorzTokenTests.test_eof_error-  s    : 	A 	AA"";// -28V,,,- - - - - - - - - - - - - - -MM,c",.?.?@@@@	A 	As   ?A	A	N)__name__
__module____qualname__test.supportr   test.support.warnings_helperr   r6   rO   rR   rT   r]   rg   rx   r   r   r   r   rQ   r7   r5   r-   r-   h   s        //////AAAAAA; ; ;": ": ":HT T T  = = =1 1 10 0 0,%! %! %!N& & &P5 5 5
A A A A Ar7   r-   var_annot_globalc                        e Zd Zd Zd Zd ZdS )CNSc                     i | _         d S N_dctr\   s    r5   __init__zCNS.__init__9  s    			r7   c                 >    || j         |                                <   d S r   )r   lower)r3   itemvalues      r5   __setitem__zCNS.__setitem__;  s    "'	$**,,r7   c                     | j         |         S r   r   r3   r   s     r5   __getitem__zCNS.__getitem__=  s    yr7   Nr   r   r   r   r   r   rQ   r7   r5   r   r   8  sA          ( ( (    r7   r   c                      e Zd ZddlmZ ddlmZ ddlmZ d Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%d# Z&d$ Z'd% Z(d& Z)d' Z* e+j,        d(d)          d*             Z-d+ Z.d, Z/d- Z0d. Z1d/ Z2d0 Z3d1 Z4d2 Z5d3 Z6d4 Z7d5 Z8d6 Z9d7 Z:d8 Z;d9 Z<d: Z=d; Z>d< Z?d= Z@d> ZAd? ZBd@ ZCdA ZDdB ZEdC ZFdD ZGdE ZHdF ZIdG ZJdH ZKdI ZLdJS )KGrammarTestsr   r   r   )check_no_warningsc                 $    t          d          }d S )Nz	1, 0 or 1)rI   r2   s     r5   test_eval_inputzGrammarTests.test_eval_inputP  s    r7   c                     d}dg}d }t            t          g d d| |            dz
  <   |                     |dg           d S )N   *   c                      dS NrW   rQ   rQ   r7   r5   onez/GrammarTests.test_var_annot_basics.<locals>.oneY  s    1r7   r   rW   )intlistr1   )r3   var1my_lstr   s       r5   test_var_annot_basicsz"GrammarTests.test_var_annot_basicsT  s_    	 	 		q ssuuQw!%%%%%r7   c                 &   t          | d           t          | d           t          | d           t          | d           t          | d           t          | d           t          | d           t          | d           t          | d	           d S )
Nz
def f: intzx: int: strzdef f():
    nonlocal x: int
z[x, 0]: int
z	f(): int
z	(x,): intz"def f():
    (x, y): int = (1, 2)
z!def f():
    x: int
    global x
z!def f():
    global x
    x: int
r   r\   s    r5   test_var_annot_syntax_errorsz)GrammarTests.test_var_annot_syntax_errors`  s    4...4///4 "9 	: 	: 	: 	41114...4---4 "> 	? 	? 	? 	4 "2 	3 	3 	3 	4 "0 	1 	1 	1 	1 	1r7   c                    |                      t                    5  ddz  t          t          <   d d d            n# 1 swxY w Y   |                      t                    5  dt          t          <   d d d            n# 1 swxY w Y   d }|                     |j        i            d } |             d }|                      t                    5   |             d d d            n# 1 swxY w Y   d }	  |             n?# t          $ r2}| 	                    t          |          t                     Y d }~nd }~ww xY w G d d          }|                     |j        t          t          d	           |                      t                    5   G d
 d          }d d d            n# 1 swxY w Y   |                      t                    5   G d d|          }d d d            d S # 1 swxY w Y   d S )NrW   r   c                  "    d} dt           _        | S )NHellorW   r/   ab)sts    r5   fz6GrammarTests.test_var_annot_basic_semantics.<locals>.f}  s    BACIr7   c                      d S r   rQ   rQ   r7   r5   f_OKz9GrammarTests.test_var_annot_basic_semantics.<locals>.f_OK        r7   c                  $    t          |            d S r   printr4   s    r5   fbadz9GrammarTests.test_var_annot_basic_semantics.<locals>.fbad  s    !HHHHHr7   c                  .    t          t                     d S r   )r   no_such_globalrQ   r7   r5   f2badz:GrammarTests.test_var_annot_basic_semantics.<locals>.f2bad  s    .!!!!!r7   c                   2    e Zd ZU eed<   dZeed<   dZd ZdS )6GrammarTests.test_var_annot_basic_semantics.<locals>.C_C__fooattrrN   r/   c                     || _         d S r   r   r2   s     r5   r   z?GrammarTests.test_var_annot_basic_semantics.<locals>.C.__init__  s    r7   N)	r   r   r   r   __annotations__rN   r   zr   rQ   r7   r5   Cr     s@         JJJAsOOOA         r7   r   )r   rN   c                   "    e Zd ZU de_        e dS )9GrammarTests.test_var_annot_basic_semantics.<locals>.CBadr   N)r   r   r   no_such_name_definedr   r   rQ   r7   r5   CBadr     s          12$)3222r7   r   c                   ,    e Zd ZU eed<   g e_        e dS ):GrammarTests.test_var_annot_basic_semantics.<locals>.Cbad2r4   N)r   r   r   r   r   r4   r   r   rQ   r7   r5   Cbad2r     s$         Tr7   r   )rG   ZeroDivisionErrorno_namedoes_not_existre   r1   r   UnboundLocalError	ExceptionassertIsrF   r   r   )	r3   r   r   r   r   er   r   r   s	            r5   test_var_annot_basic_semanticsz+GrammarTests.test_var_annot_basic_semanticst  s   011 	9 	956qSGN#	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9y)) 	- 	-+,GN#	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-
	 	 	 	*B///	 	 		 	 	 011 	 	DFFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 		" 	" 	"	.EGGGG 	. 	. 	.MM$q''9--------	.	  	  	  	  	  	  	  	  	*#,F,FGGGy)) 	3 	33 3 3 3 3 3 3 3	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 y)) 	 	       	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sm   :>>A;;A?A?C%%C),C)4
C? ?
D;	(D66D;F''F+.F+G((G,/G,c                     G d d          } G d d|          } G d d|          } G d d          } G d	 d
||          } G d d||          }|                      |j        dt          i           |                      |j        i            |                      |j        dt          i           |                      |j        dt          i           |                      |j        i            |                      |j        i            d S )Nc                       e Zd ZU eed<   dS )4GrammarTests.test_annotations_inheritance.<locals>.Ar   Nr   r   r   r   r   rQ   r7   r5   Ar              IIIIIr7   r  c                       e Zd ZdS )4GrammarTests.test_annotations_inheritance.<locals>.BNr   r   r   rQ   r7   r5   Br            Dr7   r  c                       e Zd ZU eed<   dS )4GrammarTests.test_annotations_inheritance.<locals>.Cr   N)r   r   r   r   r   rQ   r7   r5   r   r
    r  r7   r   c                       e Zd ZU eed<   dS )4GrammarTests.test_annotations_inheritance.<locals>.Dattr2Nr  rQ   r7   r5   Dr    s         JJJJJr7   r  c                       e Zd ZdS )4GrammarTests.test_annotations_inheritance.<locals>.ENr  rQ   r7   r5   Er    r  r7   r  c                       e Zd ZdS )4GrammarTests.test_annotations_inheritance.<locals>.FNr  rQ   r7   r5   Fr    r  r7   r  r   r  )r1   r   r   r   )r3   r  r  r   r  r  r  s          r5   test_annotations_inheritancez)GrammarTests.test_annotations_inheritance  s   	 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	1 	 	 		 	 	 	 	1 	 	 	*VSM:::*B///*VcN;;;*WsO<<<*B///*B/////r7   c                      G d dt                     } G d d|          }|                     |j        d         d           d S )Nc                   $    e Zd Zed             ZdS )>GrammarTests.test_var_annot_metaclass_semantics.<locals>.CMetac                 "    dt                      iS Nr   )r   )metaclsnamebaseskwdss       r5   __prepare__zJGrammarTests.test_var_annot_metaclass_semantics.<locals>.CMeta.__prepare__  s    )35511r7   N)r   r   r   classmethodr  rQ   r7   r5   CMetar    s-        2 2 [2 2 2r7   r!  c                       e Zd ZU ded<   dS );GrammarTests.test_var_annot_metaclass_semantics.<locals>.CCANNOTXXN)r   r   r   r   rQ   r7   r5   CCr#    s         KKKKKr7   r&  )	metaclassxxr$  )rF   r1   r   )r3   r!  r&  s      r5   "test_var_annot_metaclass_semanticsz/GrammarTests.test_var_annot_metaclass_semantics  s    	2 	2 	2 	2 	2D 	2 	2 	2	 	 	 	 	5 	 	 	 	+D17;;;;;r7   c           	         |                      t          j        i            |                      t          j        dt          t
          t          j        t          t          f         t          t          z  d           |                      t          j	        j        dt          d           |                      t          j        i            d S )Nr/   )rW   r4   r   r   u{   )123o)r1   r   r   
ann_moduler   r   typingTuplefloatMrF   r
   r\   s    r5   test_var_annot_module_semanticsz,GrammarTests.test_var_annot_module_semantics  s    -r22233V\#s(5KRUX]R]^^	` 	` 	`5&)55	7 	7 	74b99999r7   c                    t          j        d          }|                     t                    5  |                                 d d d            n# 1 swxY w Y   |                     t                    5  |                                 d d d            n# 1 swxY w Y   |                     t                    5  |                    d           d d d            d S # 1 swxY w Y   d S )Nztest.ann_module3r   )r   import_fresh_modulerG   re   	f_bad_ann	g_bad_ann	D_bad_ann)r3   ann_module3s     r5   test_var_annot_in_modulez%GrammarTests.test_var_annot_in_module  s    $78JKKy)) 	$ 	$!!###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$y)) 	$ 	$!!###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$y)) 	% 	%!!!$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s5   AAA5BBB;CC"%C"c                     i }i }t          d||           |                     |d         dt          d           |                     t                    5  |d          d d d            d S # 1 swxY w Y   d S )Nz.'docstring'
__annotations__[1] = 2
x: int = 5
r   r/   )rW   r4   )r   r1   r   rG   KeyError)r3   gnslnss      r5   test_var_annot_simple_execz'GrammarTests.test_var_annot_simple_exec  s    r#  #	' 	' 	' 	./QS1A1ABBBx(( 	# 	#!""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s   	A**A.1A.c                    dt                      i}t          d|           |                     |d         d         t                     |                     |d         d         t                     |                     t                    5  |d         d          d d d            n# 1 swxY w Y   i  G fdd          }t          di  |                       |                     d         d         t                     d S )	Nr   z'X: int; Z: str = "Z"; (w): complex = 1jr4   r   r   c                   &    e Zd Zd Z fdZd ZdS )5GrammarTests.test_var_annot_custom_maps.<locals>.CNS2c                     i | _         d S r   r   r\   s    r5   r   z>GrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__init__  s    			r7   c                 &    || j         |<   ||<   d S r   r   r3   r   r   	nonloc_nss      r5   r   zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__setitem__      "'	$"'	$r7   c                     | j         |         S r   r   r   s     r5   r   zAGrammarTests.test_var_annot_custom_maps.<locals>.CNS2.__getitem__      y&r7   Nr   )rG  s   r5   CNS2rC    sL          ( ( ( ( (' ' ' ' 'r7   rK  z
x: int = 1)r   r   r1   r   r   rG   r=  )r3   nsrK  rG  s      @r5   test_var_annot_custom_mapsz'GrammarTests.test_var_annot_custom_maps  sV   '6;;;-.s3S999-.s3S999x(( 	' 	' !#&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'		' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	\2ttvv&&&#45c:C@@@@@s   
B%%B),B)c                     t                      di G fdd          }t          di  |                       |                     d         d         t                     d S )Nr   c                   *    e Zd Z fdZfdZd ZdS )1GrammarTests.test_var_annot_refleak.<locals>.CNS2c                     di| _         d S r  r   )r3   cnss    r5   r   z:GrammarTests.test_var_annot_refleak.<locals>.CNS2.__init__  s    .4			r7   c                 &    || j         |<   ||<   d S r   r   rF  s      r5   r   z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__setitem__  rH  r7   c                     | j         |         S r   r   r   s     r5   r   z=GrammarTests.test_var_annot_refleak.<locals>.CNS2.__getitem__  rJ  r7   Nr   )rR  rG  s   r5   rK  rP    sV        5 5 5 5 5( ( ( ( (' ' ' ' 'r7   rK  zX: strr4   )r   r   r1   r   )r3   rK  rR  rG  s     @@r5   test_var_annot_refleakz#GrammarTests.test_var_annot_refleak  s     ee&,		' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	Xr4466"""#45c:C@@@@@r7   c                 d   i }t          d|           |                     |d         d           d}t          ||           |                     t           |d                               d g           dddt          j        d	}t          d
|           |                     |d         d           d S )Nzx: tuple = 1, 2r4   r   zdef f():
    x: int = yieldr   rW   r/         r   )r   r   cr1  zx: Tuple[int, ...] = a,*b,crW   r/   rX  rY  r   )r   r1   r   r0  r1  )r3   rL  stmts      r5   test_var_annot_rhszGrammarTests.test_var_annot_rhs  s    ###C&)))%T2gbgii4&1119!flCC*B///C/22222r7   c                    d } |              |d   |di i  d }d }|                      |j        j        d           |                      |j        j        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            |ddd            |dddd            |dddddddddd
  
         dd}	 |	              |	d            |	d   |	g pdg   |	g di odR i i   |	di ddi  |	di ddipi  dd}
 |
d            |
dd            |
di ddi dd} |dd            |ddd            |d   |dgdR    |ddgdR    |d!i ddi d!d } |              |d            |dd            |d!   |dgd"R    |di ddi  |di 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i ddi dd(} |d            |dd            |ddd           dd)} |dd            |ddd            |dddd            |d'   |d!i ddi d!d*} |              |d            |dd            |ddd            |dgd+R    |di ddd# d!d,} |d            |dd            |ddd            |dddd            |d'   |ddgd-R    |dgd"R i ddi d!d.} |dd            |ddd            |dddd            |ddddd            |d'   |ddgd-R    |dgdR i d/di t          j                    5  t          j        d0t                     	 t          di d2di |                     d3           n# t          $ r Y nw xY wd d d            n# 1 swxY w Y   d4 } |d56           d5d7d8} |ddd59            |ddd5d:;            |ddd5d:<           d5d9d=} |ddd5d5d:>            |ddd5d:d5?           | 
                    t          t          d@           | 
                    t          t          dA           | 
                    t          t          dB           dC }|                       |dgddgR dddDdEdddDf           |                       |dgddR  d'i f           | 
                    t          t          dF           |                       |di dGdHdIddGdHdIf           |                       |ddJdHidKdGiddGdHdIf           t          | dL           t          | dM           dNt          fdO}|                      |j        dNt          i           d1t           fdP}|                      |j        d1t           i           d1t           fdQ}|                      |j        d1t           i           dd1t           fdS}|                      |j        d1t           i           d1t          fdT}|                      |j        d1t          i           d1t"          fdU}|                      |j        d1t"          i           ddW}|                      |j        dVdi           ddX}|                      |j        dVdi           ddY}|                      |j        dddZ           dd[}|                      |j        dddZ           ddd^}|                      |j        ddddd_           ddd`da	 	 	 ddg}|                      |j        dddddddedfdh           ddd`daddddd\ddit           d]ddbddcddddedNdffdj}|                      |j        dddt           ddddedfdk	            G dl dm          } G dn do|          }|                      |j        j        dpdi           |                      |j        j        dpdi           dq dNt          fdr            }|                      |j        dNt          i           dt             }x}du             }fdvdw             }dxdxgd         dy             }                      dz             }gd         j        j        d{             }dfd|}dfd}	}dd~fd
}dNt           ffd}d }d }d }d }d }d }d }d }d }d }d }d }d }d }d }d S )Nc                      d S r   rQ   rQ   r7   r5   f1z%GrammarTests.test_funcdef.<locals>.f1  r   r7   rQ   c                     d S r   rQ   one_arguments    r5   f2z%GrammarTests.test_funcdef.<locals>.f2!  r   r7   c                     d S r   rQ   two	argumentss     r5   f3z%GrammarTests.test_funcdef.<locals>.f3"  r   r7   rb  rf  c                     d S r   rQ   )one_args    r5   a1z%GrammarTests.test_funcdef.<locals>.a1%  r   r7   c                     d S r   rQ   )rg  argss     r5   a2z%GrammarTests.test_funcdef.<locals>.a2&  r   r7   c                      d S r   rQ   rests    r5   v0z%GrammarTests.test_funcdef.<locals>.v0'  r   r7   c                     d S r   rQ   r   rr  s     r5   v1z%GrammarTests.test_funcdef.<locals>.v1(  r   r7   c                     d S r   rQ   r   r   rr  s      r5   v2z%GrammarTests.test_funcdef.<locals>.v2)  r   r7   rW   r/   rX  rY  r            r:   r   c                     d S r   rQ   r   s    r5   d01z&GrammarTests.test_funcdef.<locals>.d01?  r   r7   rW   r   c                     d S r   rQ   r   s     r5   d11z&GrammarTests.test_funcdef.<locals>.d11G  r   r7   r   c                     d S r   rQ   r   r   rZ  s      r5   d21z&GrammarTests.test_funcdef.<locals>.d21K  r   r7   rW   r/   rX  r/   rX  rX  rZ  c                     d S r   rQ   r   s     r5   d02z&GrammarTests.test_funcdef.<locals>.d02R  r   r7   r   r/   r   c                     d S r   rQ   r  s      r5   d12z&GrammarTests.test_funcdef.<locals>.d12Z  r   r7   c                     d S r   rQ   r   r   rZ  ds       r5   d22z&GrammarTests.test_funcdef.<locals>.d22^  r   r7   c                     d S r   rQ   ru  s     r5   d01vz'GrammarTests.test_funcdef.<locals>.d01vb  r   r7   )rW   r/   rX  rY  c                     d S r   rQ   rx  s      r5   d11vz'GrammarTests.test_funcdef.<locals>.d11vi  r   r7   c                     d S r   rQ   r   r   rZ  rr  s       r5   d21vz'GrammarTests.test_funcdef.<locals>.d21vm  r   r7   c                     d S r   rQ   rx  s      r5   d02vz'GrammarTests.test_funcdef.<locals>.d02vs  r   r7   rW  c                     d S r   rQ   r  s       r5   d12vz'GrammarTests.test_funcdef.<locals>.d12vz  r   r7   rX  rY  r   c                     d S r   rQ   )r   r   rZ  r  rr  s        r5   d22vz'GrammarTests.test_funcdef.<locals>.d22v  r   r7   r  rV   r4   s   fooz/Bytes should not work as keyword argument namesc                     | S r   rQ   keys    r5   pos0key1z+GrammarTests.test_funcdef.<locals>.pos0key1  s    Sjr7   d   r  )k2c                    | |||fS r   rQ   )p1p2k1r  s       r5   pos2key2z+GrammarTests.test_funcdef.<locals>.pos2key2  s    Br"RK-?r7   )r     )r  r  )r  r  c                    | ||||fS r   rQ   )r  r  r  r  kwargs        r5   pos2key2dictz/GrammarTests.test_funcdef.<locals>.pos2key2dict  s    Br"UAR:Rr7   )r  tokwarg1tokwarg2)r  r  r  zdef f(*): passzdef f(*,): passzdef f(*, **kwds): passc                  
    | |fS r   rQ   )rn  kwargss     r5   r   z$GrammarTests.test_funcdef.<locals>.f  s    <r7   r4   r   )rW   rX  rY  zf(1, x=2, *(3,4), x=5)	scrambledfried)eggsr   r   r  z
f(*g(1=2))zf(**g(1=2))returnc                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                    d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   r   c                    d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                      d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                      d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   r   c                     d S r   rQ   r  s     r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                    d S r   rQ   r  s     r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                     d S r   rQ   r  s       r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   )r   rZ  c                    d S r   rQ   r  s       r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   r   gc                     d S r   rQ   )r   r   rZ  r  r   r   r  s          r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   )r   rZ  r   r  
   )ijhr  k      c                    d S r   rQ   r   r   rZ  r  r   r   r  r  r  r  r  s              r5   r   z$GrammarTests.test_funcdef.<locals>.f      "dr7   )r   rZ  r   r  r  r  r  r  r   c                   d S r   rQ   r  s              r5   r   z$GrammarTests.test_funcdef.<locals>.f  r  r7   )	r   rZ  r   r   r  r  r  r  r  c                       e Zd ZddZdS )'GrammarTests.test_funcdef.<locals>.Spam	_Spam__kwrW   c                    d S r   rQ   )r3   r  s     r5   r   z)GrammarTests.test_funcdef.<locals>.Spam.f      r7   N)r  rW   )r   r   r   r   rQ   r7   r5   Spamr    s(             r7   r  c                       e Zd ZdS )&GrammarTests.test_funcdef.<locals>.HamNr  rQ   r7   r5   Hamr              r7   r  r  c                     | S r   rQ   r   s    r5   nullz'GrammarTests.test_funcdef.<locals>.null  s    AXr7   c                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  s    $r7   Fc                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f      $r7   c                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r  r7   c                      |           S r   rQ   )r   r  s    r5   <lambda>z+GrammarTests.test_funcdef.<locals>.<lambda>  s    4477 r7   c                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r  r7   .c                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r  r7   c                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r  r7   c                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r  r7   c                       S r   rQ   closures   r5   r   z$GrammarTests.test_funcdef.<locals>.f  s    r7   c                     S r   rQ   )r4   r  s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  s    7Nr7   r  c                     S r   rQ   )r  r  s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  s    g~r7   c                       S r   rQ   r  s   r5   r   z$GrammarTests.test_funcdef.<locals>.f  s    wr7   c                     d S r   rQ   r~  s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                      d S r   rQ   rn  s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                      d S r   rQ   r  s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                     d S r   rQ   r   rn  s     r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                     d S r   rQ   r   r  s     r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                     d S r   rQ   r   rn  s     r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                     d S r   rQ   r   s    r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                      d S r   rQ   rn  r  s     r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                    d S r   rQ   r   r   rn  s      r5   r   z$GrammarTests.test_funcdef.<locals>.f   r   r7   c                    d S r   rQ   r   s     r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                     d S r   rQ   r   rn  r  s      r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                     d S r   rQ   r   rn  r  s      r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                     d S r   rQ   r   r  s     r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                    d S r   rQ   r   r   rn  r  s       r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   c                    d S r   rQ   r   r   r  s      r5   r   z$GrammarTests.test_funcdef.<locals>.f  r   r7   r   )r   )r   rX  )r   rW   rZ  r/   )rZ  r/   r   rW   )rY  r   )r   rW   rZ  r/   r   rX  r  rz  )r   rW   rZ  r/   r   rX  r  rz  r  r{  r  r:   r  r  r  r  )r1   __code__co_varnamesrX   rY   rZ   BytesWarningr   rM   	TypeErrorrG   rH   rI   r   r   r   r   r2  r   __call__)r3   r`  rd  ri  rl  ro  rs  rv  ry  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  s                               @@r5   test_funcdefzGrammarTests.test_funcdef  s    	

B
B""""$$$02CDDD02FGGG   !!!

1
1
1a
1a			

1
1
1Q
1Qq1Qq1Q
1
1
1Q
1Qq			
1Qq1Qq1Q
1Q
1Qq			
1Qq
1Qq1Qq1QAT

RYA3.2.	r...2...s1gs1gmAAq			#a    Aq			Aq!YAAq4SGAAq			VA#aAA""""AAq			Aq!%%%%Aq			Aq!Aq!Q""""QQ


ldAw%%%%QQ


Q1((((Q


Q1Q1alc1X''''QQ


Q1Q  QQ   ****QQ


Q1Q1alQIQ""""#q"""----Q


Q1Q1aQ1alQIQ$$$$C8$$$ $&& 	M 	M!(L999M''F1;''' 		KLLLL    		M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	)((S'*?????A#A##&&&&A##&&&&'*RRRRRQqCc::::Qq#ss;;;;+t-=>>>+t->???+t-EFFF	  	  	 10QF00a00099:NN3D 	E 	E 	E1ua<*<===+t-EFFFBB[AABBk'BBC	E 	E 	E@@@F;+?@@k'BBC	E 	E 	E 	4...4/// 	D*Xt,<===*S#J777*S#J777######*S#J777#*S#J7775*S%L999*S!H555!!!!*S!H555%%%%*!!,<,<===((((*!!,<,<===;;;;;* qqq99	; 	; 	;	#a 	# 	#	#	# 	# 	# 	#* qqqqq!R1 1	2 	2 	2	#RT 	# 	# 	#A 	#! 	#1 	#S 	#Q 	#1 	#a 	#	#	# 	# 	# 	#* !!!RS "b2 2	3 	3 	3	 	 	 	 	 	 	 	 	$/+q1ABBB.a0@AAA	D 
*Xt,<===  
 
				 
	
tS	!	 
		dD		 
	
		$ 
%	$ """"""%%%%%%%&3&&&&&& 	###!!!&&&&&&""")))%%%%%s6   R,,R:R,
RR,RR,,R03R0c                    d }|                       |            d           d }d }|                       |            g d           d&dfdfd	}|                       |            d           d'd}|                       |dd
          d           |                       |dd
d          d           t          | d           t          | 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 S )(Nc                      dS Nr   rQ   rQ   r7   r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>
  s    a r7   r   c                  &    t           t                   S r   )r   r  rQ   r7   r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s
    ad r7   c                      d dD             S )Nc                     g | ]}d |k     	S r  rQ   .0r4   s     r5   
<listcomp>z?GrammarTests.test_lambdef.<locals>.<lambda>.<locals>.<listcomp>  s    111q1u111r7   )rX  r   rQ   rQ   r7   r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s    11j111 r7   )r   rW   r   rW   c                     | S r   rQ   r   s    r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s     r7   c                      |             S r   rQ   )r   s    r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s    AACC r7   c                      |             S r   rQ   r   s    r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s    !!## r7   r/   c                     | |z   |z   S r   rQ   )r4   r   r   s      r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s    q1uqy r7   r   rX  rz  zlambda x: x = 2zlambda (None,): None   r  c                    | |z   |z   S r   rQ   )r4   r   r  s      r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s    1Q3q5 r7      r     c                     dS r  rQ   r~  s    r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s     r7   c                      dS r  rQ   r  s    r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s    Q r7   c                      dS r  rQ   r  s    r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s    a r7   c                     dS r  rQ   r  s     r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>       r7   c                     dS r  rQ   r  s     r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>  s     r7   c                     dS r  rQ   r  s     r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>   r%  r7   c                     dS r  rQ   r  s    r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>!  s    A r7   c                      dS r  rQ   r  s     r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>"  s    Q r7   c                    dS r  rQ   r  s      r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>#  s    1 r7   c                    dS r  rQ   r   s     r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>$  s    q r7   c                     dS r  rQ   r  s      r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>%       r7   c                     dS r  rQ   r  s      r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>&  r-  r7   c                     dS r  rQ   r  s     r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>'  s    A r7   c                    dS r  rQ   r  s       r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>(  s    1 r7   c                    dS r  rQ   r  s      r5   r  z+GrammarTests.test_lambdef.<locals>.<lambda>)  s    q r7   r  r  r1   r   )r3   l1l2l3l4l5l6l10l11l12l13l14l15l16l17l18l19l20l21l22l23l24s                         r5   test_lambdefzGrammarTests.test_lambdef  s   Zq!!!]11yyy)))#1>>777===q!!!(((Aq1%%%Aq!a(((4!23334!7888!((((Aa&)))Aa"v... l!!""!!o&&$$  ))))%%,,((r7   c                 &    d}~d } |             d S )NrW   c                      d} ~ d S r   rQ   r   s    r5   fooz*GrammarTests.test_simple_stmt.<locals>.foo2  s    AQQQr7   rQ   )r3   r4   rK  s      r5   test_simple_stmtzGrammarTests.test_simple_stmt/  s)    	  	  	  	r7   c                     	 	 d}d}dx}x}}d\  }}}dx}x\  }}}x\  }}}}t          | d           t          | d           d S )NrW   r  )rW   r/   )rX  rY  z	x + 1 = 1za + 1 = b + 2r   )	r3   r4   r   r   abcr   r   rZ  xyzs	            r5   test_expr_stmtzGrammarTests.test_expr_stmt:  sr    	A1a(444gaA41a#4---411111r7   c           	      n   d}g d}|D ]*}d                     |          }|D ]}|                     |          }|                     |          5  |                     t          |          5  t	          |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                    dd          }|                     |          5  |                     t          d          5  t	          |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   ,d S )N)r   r   )z{} fooz{} {{1:foo}}zif 1: {} foozif 1: {} {{1:foo}}zif 1:
    {} foozif 1:
    {} {{1:foo}}zcall to '{}')sourcerK  z(foo.)zinvalid syntax)formatr   r   rH   r   rc   )r3   keywordscaseskeyword
custom_msgcaserR  s          r5   (test_former_statements_refer_to_builtinsz5GrammarTests.test_former_statements_refer_to_builtinsI  s@   "
 
 
   
	% 
	%G'..w77J % %W--\\\00 % %//ZHH % %V% % % % % % % % % % % % % % %% % % % % % % % % % % % % % %  x88\\\00 % %//=MNN % %V% % % % % % % % % % % % % % %% % % % % % % % % % % % % % %%
	% 
	%sl   B -B		=B 	BB BB  B$'B$D&3D	D&DD&DD&&D*-D*c                     g d}|\  }}}|||f}~~~~~d\  }}}~~~d\  }}}}	}
}}~~~~	~
~d\  }}}}	}
}}~~~~	~
~t          d          }|dd= t          ddd	           d S )
Nr  rO  abcdefgabcdrW   r/   z-del a, (b[0].c, (d.e, f.g[1:2])), [h.i.j], ()r~   r   )r   r   )r3   rN  r4   r   r   rO  r   r   rZ  r  r   r   r  r\  s                 r5   test_del_stmtzGrammarTests.test_del_stmt`  s    gg1aAgq1c1a (1aAq!1Aq'1aAq!1AqF||1I?vVVVVVr7   c                     d S r   rQ   r\   s    r5   test_pass_stmtzGrammarTests.test_pass_stmtz  s    r7   c                     d S r   rQ   r\   s    r5   test_break_stmtzGrammarTests.test_break_stmt  s    r7   c                     d}|rd}d}|sd}	 #  d}Y nxY w||dk    r|                      |           d}|sd}	 	 d}	# d}w xY w|dk    r|                      |           d S d S )NrW   r   r`   okz&continue failed to continue inside tryz'continue inside try called except blockzfinally block not calledrM   )r3   r  msgs      r5   test_continue_stmtzGrammarTests.test_continue_stmt  s     Q 	@C@@?  	@ $;;IIcNNN 	,Cd



$;;IIcNNNNN ;s
   Ac                 (     d fd	} |             d S )NrW   r   c                     d}|r |dz  }	 | r|dk    r| dz  } n|dz  }#   xY w|dk    s|dk    r                     d           d S d S )Nr/   rW   z1continue then break in try/except in loop broken!rd  )extra_burning_oilcount	big_hippor3   s      r5   
test_innerz9GrammarTests.test_break_continue_loop.<locals>.test_inner  s    I 	
( Y!^^)Q.)NIqyyINN		MNNNNN +Ns       #)rW   r   rQ   )r3   rl  s   ` r5   test_break_continue_loopz%GrammarTests.test_break_continue_loop  s8    	O 	O 	O 	O 	O 	O 	
r7   c                     d }d }d } |              |            } |            }|                      |dd           t          | d           d S )Nc                      d S r   rQ   rQ   r7   r5   g1z$GrammarTests.test_return.<locals>.g1  s    &&r7   c                      dS r   rQ   rQ   r7   r5   g2z$GrammarTests.test_return.<locals>.g2  s    r7   c                      ddg} dg| R S )Nr/   rX  rW   rQ   r  s    r5   g3z$GrammarTests.test_return.<locals>.g3  s    AA5q55Lr7   r  z unparenthesized star expr returnzclass foo:return 1r2  )r3   rp  rr  rt  r4   r   s         r5   test_returnzGrammarTests.test_return  sv    	 	 	 	BDDBDDI'IJJJ4!566666r7   c                    d}|dk     r|dz  }	 	 n#  Y nxY w|                      |d           d}|dk     r|dz  }	 	 n#  Y nxY w|                      |d           d}|dk     r|dz  }	 ddz   n#  Y nxY w|                      |d           dD ]#}|                      |d           	 	  n#  Y  nxY w|                      |d           dD ]#}|                      |d           	 	  n#  Y  nxY w|                      |d           dD ]'}|                      |d           	 ddz    n#  Y  nxY w|                      |d           d S Nr   r/   rW   r   rW   r0   r3   rj  s     r5   test_break_in_finallyz"GrammarTests.test_break_in_finally  s   aiiQJE"""aiiQJE"""aiiQJE!""" 	 	EUA&&&""" 	 	EUA&&&""" 	 	EUA&&&!"""""s-   A)A/ /A3*B/&C+D&&D+c                    d}|dk     r|dz  }	 	 #  Y xY w|                      |d           d}|dk     r|dz  }	 	 #  Y xY w|                      |d           d}|dk     r|dz  }	 ddz   #  Y xY w|                      |d           dD ]}	 	 #  Y 	xY w|                      |d           dD ]}	 	 #  Y 	xY w|                      |d           dD ]}	 ddz   	#  Y xY w|                      |d           d S rw  r0   ry  s     r5   test_continue_in_finallyz%GrammarTests.test_continue_in_finally  s   aiiQJE"""aiiQJE"""aiiQJE!""" 	 	E""" 	 	E""" 	 	E!"""""s-   A)A/ /A3B7B;CC#c                     d }|                       |            d           d }|                       |            d           d }|                       |            d           d S )Nc                      	 	 dS #  Y dS xY wr   rQ   rQ   r7   r5   rp  z/GrammarTests.test_return_in_finally.<locals>.g11  s    qqqqqqqq   
rW   c                      	 	 dS #  Y dS xY w)NrX  rQ   rQ   r7   r5   rr  z/GrammarTests.test_return_in_finally.<locals>.g28  s    qqqqqqqqr  rX  c                  "    	 ddz   dS #  Y dS xY w)NrW   r   rY  rQ   rQ   r7   r5   rt  z/GrammarTests.test_return_in_finally.<locals>.g3?  s$    !qqqqqqqqs   	 rY  r0   )r3   rp  rr  rt  s       r5   test_return_in_finallyz#GrammarTests.test_return_in_finally0  s    	 	 	
 	q!!!	 	 	
 	q!!!	 	 	
 	q!!!!!r7   c                 
   d }|                       |d          d           |                       |d          d           d }|                       |d          d           |                       |d          d           d S )Nc                 \    dD ]%}d}|dk     r|dz  }	 ||z   | r nc S # | r Y nw xY w&d||fS )Nrx  r   r  r  endrQ   r4   rj  count2s      r5   rp  z;GrammarTests.test_break_in_finally_after_return.<locals>.g1H  su     " "rkkbLF"$v~ "!E" " "1 "!EEEEEE%''s   %%Fr  T)r  rW   r  c                 R    dD ] }dD ]}	 ||z   | r  nc c S # | r Y  nw xY w!d||fS )Nrx  )r  r  r  rQ   r  s      r5   rr  z;GrammarTests.test_break_in_finally_after_return.<locals>.g2V  s{     " "& " "F"$v~ "!EE" " " " "1 "!EEEEEEE%''s     r0   r3   rp  rr  s      r5   "test_break_in_finally_after_returnz/GrammarTests.test_break_in_finally_after_returnF  s    
	( 
	( 
	( 	EB'''D>222	( 	( 	( 	EB'''D>22222r7   c                 
   d }|                       |d          d           |                       |d          d           d }|                       |d          d           |                       |d          d           d S )	Nc                 F    d}|dk     r|dz  }	 || r S # | r Y w xY wd|fS )Nr   r  rW   r  rQ   r4   rj  s     r5   rp  z>GrammarTests.test_continue_in_finally_after_return.<locals>.g1d  sT    E#++
!  ! !q ! %<s    FrW   T)r  r  c                 8    dD ]}	 || r c S # | r Y w xY wd|fS )Nrx  r  rQ   r  s     r5   rr  z>GrammarTests.test_continue_in_finally_after_return.<locals>.g2q  sV     ! !!  ! ! ! !q ! %<s   r   )r  rW   r0   r  s      r5   %test_continue_in_finally_after_returnz2GrammarTests.test_continue_in_finally_after_returnb  s    		  		  		  	EA&&&D<000	  	  	  	EA&&&D:.....r7   c                 L   d }d }d }d }d }d }t          | d           t          | d           d	 }d
 }t          | d           t          | d           d }d }d }d }d }|                     t           |                      dg           t          | d           t          | d           t          | d           t          | d           t          | d           t          | d           t          | d           t          | d           t          | d           d S )Nc               3      K   dV  d S r   rQ   rQ   r7   r5   r  z"GrammarTests.test_yield.<locals>.g~  s      qr7   c               3      K   dE d {V  d S NrQ   rQ   rQ   r7   r5   r  z"GrammarTests.test_yield.<locals>.g  s      Br7   c               3      K   dV } d S r   rQ   r   s    r5   r  z"GrammarTests.test_yield.<locals>.g  s      1WWr7   c               3      K   dE d {V } d S r  rQ   r   s    r5   r  z"GrammarTests.test_yield.<locals>.g  s      ]]]]]]r7   c               3      K   dV  d S N)rW   rW   rQ   rQ   r7   r5   r  z"GrammarTests.test_yield.<locals>.g  s      tr7   c               3      K   dV } d S r  rQ   r   s    r5   r  z"GrammarTests.test_yield.<locals>.g  s      4ZZr7   zdef g(): yield from (), 1zdef g(): x = yield from (), 1c               3      K   ddV f d S r   rQ   rQ   r7   r5   r  z"GrammarTests.test_yield.<locals>.g  s      1WWr7   c               3      K   ddE d {V f d S NrW   rQ   rQ   rQ   r7   r5   r  z"GrammarTests.test_yield.<locals>.g  s"      ]]]]]]####r7   zdef g(): 1, yield 1zdef g(): 1, yield from ()c               3   ,   K   t          dV            d S r   r   rQ   r7   r5   r  z"GrammarTests.test_yield.<locals>.g  s      !GGr7   c               3   .   K   t          dV d           d S r   r  rQ   r7   r5   r  z"GrammarTests.test_yield.<locals>.g  s      !GGar7   c               3   4   K   t          dE d {V            d S r  r  rQ   r7   r5   r  z"GrammarTests.test_yield.<locals>.g  s%      rMMMMMM#####r7   c               3   6   K   t          dE d {V d           d S )NrQ   rW   r  rQ   r7   r5   r  z"GrammarTests.test_yield.<locals>.g  s'      rMMMMMMA&&&&&r7   c               3   "   K   d} dddg| R V  d S )NrY  r   rz  rW   r/   rX  rQ   rq  s    r5   r  z"GrammarTests.test_yield.<locals>.g  s'      q!Q~~~!5!5!5!5!5r7   )rW   r/   rX  rY  r   rz  zdef g(): f(yield 1)zdef g(): f(yield 1, 1)zdef g(): f(yield from ())zdef g(): f(yield from (), 1)yieldz
yield fromzclass foo:yield 1zclass foo:yield from ()zdef g(a:(yield)): pass)r   r1   r   )r3   r  s     r5   
test_yieldzGrammarTests.test_yield|  s~   """4!<===4!@AAA###4!67774!<===   ###&&&555aacc%7$89994!67774!9:::4!<===4!?@@@4)))4...4!45554!:;;;4!9:::::r7   c                    d }d }| j         } |dd            |dd            |dd            |dd            |d	d
            |dd
            |dd            |dd            |dd            |dd           d S )Nc               3   (   K   d dV fD              d S )Nc                     g | ]}|S rQ   rQ   r  s     r5   r  zHGrammarTests.test_yield_in_comprehensions.<locals>.g.<locals>.<listcomp>  s    )))!)))r7   rW   rQ   rQ   r7   r5   r  z4GrammarTests.test_yield_in_comprehensions.<locals>.g  s&      ))Qww[))))))r7   c               3   0   K   d dE d {V fD              d S )Nc                     g | ]}|S rQ   rQ   r  s     r5   r  zHGrammarTests.test_yield_in_comprehensions.<locals>.g.<locals>.<listcomp>  s    ///!///r7   rQ   rQ   rQ   r7   r5   r  z4GrammarTests.test_yield_in_comprehensions.<locals>.g  s/      //"}}}}}}.//////r7   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   )r3   r  rw   s      r5   test_yield_in_comprehensionsz)GrammarTests.test_yield_in_comprehensions  s*   )))///'01	3 	3 	391	3 	3 	3=1	3 	3 	300	2 	2 	231	3 	3 	331	3 	3 	303	5 	5 	551	3 	3 	301	3 	3 	3'1	3 	3 	3 	3 	3r7   c                 p    t          d          # t           $ r Y nw xY wt          # t          $ r Y d S w xY w)Nzjust testing)RuntimeErrorKeyboardInterruptr\   s    r5   
test_raisezGrammarTests.test_raise  sF    ///!!!TT!$$ &&&$$$&s    
' 
55c                 f    dd l }dd l}dd l }ddlm} ddlm} ddl m}m} ddl m}m} ddl m}m} d S )Nr   )time)pathargv)rJ   r  r  r  )r3   rJ   r  r  r  s        r5   test_importzGrammarTests.test_import  s    


 	#"""""""$$$$$$$$%%%%%%%%%%r7   c                     d S r   rQ   r\   s    r5   test_globalzGrammarTests.test_global  r   r7   c                     ddfd}d S )Nr   c                      d S r   rQ   r  s   r5   r   z%GrammarTests.test_nonlocal.<locals>.f  s      r7   rQ   )r3   r   r4   r   s     @@r5   test_nonlocalzGrammarTests.test_nonlocal  s6    	 	 	 	 	 	 	 	r7   c                     	 	 d sJ 	 	 n,# t           $ r}|                     d           Y d }~nd }~ww xY w	 d S # t           $ r }|                     d           Y d }~d S d }~ww xY w)NrW   c                     | S r   rQ   r   s    r5   r  z*GrammarTests.test_assert.<locals>.<lambda>  s     r7   c                     | dz   S r   rQ   r   s    r5   r  z*GrammarTests.test_assert.<locals>.<lambda>  s
    1Q3 r7   Tz6'assert True' should not have raised an AssertionErrorzthis should always passz;'assert True, msg' should not have raised an AssertionError)AssertionErrorrM   r3   r   s     r5   test_assertzGrammarTests.test_assert  s    z	P 	P 	P 	PIINOOOOOOOO	P	222 	2 	2 	2II 1 2 2 2 2 2 2 2 2 2	2s   
4/4
A$AA$Tz Won't work if __debug__ is Falsec                    	 J d            # t          $ r+}|                     |j        d         d           Y d }~nd }~ww xY w	 J # t          $ r3}|                     t	          |j                  d           Y d }~d S d }~ww xY w)Nr   re  )rM   r  r1   rn  r   r  s     r5   test_assert_failuresz!GrammarTests.test_assert_failures  s    	?eOOO 	/ 	/ 	/QVAY........	/
	EL 	- 	- 	-S[[!,,,,,,,,,	-s*   
 
A!<AA 
B(A??Bc                 6   |                      dd           |                      dd           |                      dd           |                     t                    5  t          ddd           t          d	dd           d d d            d S # 1 swxY w Y   d S )
Nassert(x, "msg")zassertion is always trueassert(False, "msg")assert(False,))categoryzassert x, "msg"r~   r   zassert False, "msg")r   r   r[   r   r\   s    r5   test_assert_syntax_warningsz(GrammarTests.test_assert_syntax_warnings  s    	!!"4"<	> 	> 	>!!"8"<	> 	> 	>!!"2"<	> 	> 	> ##]#;; 	A 	A%|V<<<)<@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	As   #BBBc                    t          j                    5  t          j        dt                     	 t	          ddd           n%# t
          $ r |                     d           Y nw xY w|                     t
                    5  t	          ddd           d d d            n# 1 swxY w Y   |                     t
                    5  t	          ddd           d d d            n# 1 swxY w Y   |                     t
                    5  t	          ddd           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )	Nr   zassert x, "msg" r~   r   z4SyntaxError incorrectly raised for 'assert x, "msg"'r  r  r  )rX   rY   rZ   r[   r   rH   rM   rG   r\   s    r5   ,test_assert_warning_promotes_to_syntax_errorz9GrammarTests.test_assert_warning_promotes_to_syntax_error  s    $&& 	@ 	@!'=999T*L&AAAA T T T		RSSSSST"";// B B*L&AAAB B B B B B B B B B B B B B B"";// F F.fEEEF F F F F F F F F F F F F F F"";// @ @(,???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s   D=AD=A$!D=#A$$D=BD=B#	#D=&B#	'D=C"D="C&	&D=)C&	*D=D%D=%D)	)D=,D)	-D==EEc                     	 	 	 	 	 	 	 	 d S r   rQ   r\   s    r5   test_ifzGrammarTests.test_if&  s)    					dr7   c                 B    	 	 	 d}	 d}|                      |d           d S )Nr   rW   r/   r0   r2   s     r5   
test_whilezGrammarTests.test_while3  s<    	 	 AAr7   c                    dD ]}dD ]\  }}}	  G d d          }d} |d          D ]}||z   }|dk    r|                      d           g }d	D ]\  }|                    |           |                     |g d           g }g dx}x}	}
g ||	|
R D ]}|                    |           |                     |d
|z             d S )Nr  rQ   c                        e Zd Zd Zd Zd ZdS )&GrammarTests.test_for.<locals>.Squaresc                 "    || _         g | _        d S r   )maxsofar)r3   r  s     r5   r   z/GrammarTests.test_for.<locals>.Squares.__init__H  s    


r7   c                 *    t          | j                  S r   )r   r  r\   s    r5   __len__z.GrammarTests.test_for.<locals>.Squares.__len__K  s    c$*oo5r7   c                     d|cxk    r| j         k     s	n t          t          | j                  }||k    r(| j                            ||z             |dz   }||k    (| j        |         S )Nr   rW   )r  
IndexErrorr   r  append)r3   r  ns      r5   r   z2GrammarTests.test_for.<locals>.Squares.__getitem__L  sz    A((((((((
*:
OO1ffJ%%ac***!A 1ff z!}$r7   N)r   r   r   r   r  r   rQ   r7   r5   Squaresr  G  s=              655% % % % %r7   r  r   r  i  zfor over growing sequence)r  r  r  rX  )rM   r  r1   )r3   r  r  r  r  r  r4   resultr   r   rZ  s              r5   test_forzGrammarTests.test_forB  s@   AA 	 	GAq!!	% 	% 	% 	% 	% 	% 	% 	% %%A!A#aa88II1222$ 	 	BAMM!+++IIA!a! 	 	AMM!Q'''''r7   c                    	 ddz   n# t           $ r Y nw xY wddz   n$# t          $ r Y nt          $ r
}Y d }~n
d }~w Y nxY wddz   n# t          t          t           f$ r Y nw xY wddz   n$# t          t          t           f$ r
}Y d }~nd }~ww xY w	 n# w xY w|                     t                    5  t          ddd           t          ddd           d d d            d S # 1 swxY w Y   d S )NrW   r   z/try:
    pass
except Exception as a.b:
    pass?r   z0try:
    pass
except Exception as a[b]:
    passr   EOFErrorr  rG   rH   r   r3   re  s     r5   test_tryzGrammarTests.test_tryc  s   	aCC  ! 	 	 	D	 qSS  %%%qSSS)%67====qSSS)%67DDDD{++ 	X 	XH#vVVVI3PVWWW	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	XsX    
 
?	??A A"!A"%A+ +BBB0#C  C$'C$c                    	 ddz   n!# xg ct           % x n nn X x Y ncY w xY w	 ddz   n7# xg ct          % x n nn t           % x}d }~nd }~ nn X x Y ncY w xY w	 ddz   n.# xg ct          t          t           f% x n nn X x Y ncY w xY wddz   n4# xg ct          t          t           f% x}d }~nd }~ nn X x Y ncY w xY w	 n# w xY w|                     t                    5  t          ddd           t          ddd           t          ddd           d d d            d S # 1 swxY w Y   d S )NrW   r   z0try:
    pass
except* Exception as a.b:
    passr  r   z1try:
    pass
except* Exception as a[b]:
    passztry:
    pass
except*:
    passr  r  s     r5   test_try_starzGrammarTests.test_try_star|  s   	aCCC	 	 	! 	 	 	 	D	 qSSS$$!....$$$$$.qSSS>>>9&78>>>>$$>qSSSEEE9&78EEEEE{++ 	G 	GI3PVWWWJCQWXXX8#vFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	GsA    &0 /A$(A. .&BB" ",CC74D88D<?D<c                     	 	 	 	 	 	 d S r   rQ   r\   s    r5   
test_suitezGrammarTests.test_suite  s    		 Dr7   c                     	 	 	 	 	 d S r   rQ   r\   s    r5   	test_testzGrammarTests.test_test  s     	"48Dr7   c                    	 ddk    }ddk    r	 ddk    r	 ddk     r	 ddk    r	 ddk    r	 ddk    r	 ||u r	 ||ur	 ddv r	 ddvr	 ddcxk     r6dcxk    r/dcxk    r(dcxk    r!dcxk    rdcxk    rdcxv r|cxvr	|cxu r|urn d S d S d S r  rQ   r2   s     r5   test_comparisonzGrammarTests.test_comparison  s    !V664664q55$q55$664664664A::t77DB;;qDDDD1DDDDDDDDQDDDD!DDDDqDDDDADDDDQDDDD!DDDD1DDDDDDddDDr7   c                     d fd	} |d            |d            |d            |d            |dd           t          j                    5  t          j        d	t                     t	          d
dd           t	          ddd           t	          ddd           t	          ddd           d d d            d S # 1 swxY w Y   d S )Nr   c                 4                         | |           d S r   r   r   re  r3   s     r5   rw   z6GrammarTests.test_comparison_is_literal.<locals>.check      %%dC00000r7   zx is 1zx is "thing"z1 is xzx is y is 1z
x is not 1z"is not" with a literalr   z	x is Noner~   r   z
x is Falsez	x is Truezx is ...)r   rX   rY   rZ   r[   r   rv   s   ` r5   test_comparison_is_literalz'GrammarTests.test_comparison_is_literal  s>   	1 	1 	1 	1 	1 	1 	hnhml5666$&& 	6 	6!'=999Kv666L,777Kv666Jf555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s   AB??CCc                 >     f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-            |d.           d/ |d0            |d1           d2 |d3            |d4           d5 |d6           d7 |d8           d9 |d:            |d;            |d<           d= |d>            |d?            |d@            |dA            |dB           t          j                    5  t          j        dCt                     t	          dDdEdF           t	          dGdEdF           t	          dHdEdF           t	          dIdEdF           t	          dJdEdF           t	          dKdEdF           d d d            d S # 1 swxY w Y   d S )LNc                 4                         |            d S r   r   r  s    r5   rw   z2GrammarTests.test_warn_missed_comma.<locals>.check  r  r7   z-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~   r   z[[1, 2] [i]]z[[1, 2] [0]]z[[1, 2] [True]]z[[1, 2] [1:2]]z[{(1, 2): 3} [i, j]]r  )r3   rw   re  s   ` @r5   test_warn_missed_commaz#GrammarTests.test_warn_missed_comma  s   	1 	1 	1 	1 	1 	1 =               .///.///.///1222   !"""   nooonA   .///.///)***nooonZ         .///   !"""   =   <!"""0111;!"""0111<!"""3444A0111@+,,,;!"""#$$$ !!!6!"""    !!!   $&& 	B 	B!'=999/vFFFNL&999NL&999%|V<<<$lF;;;*L&AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs   BLLLc                     d}d}d}d S )NrW   r   rQ   r2   s     r5   test_binary_mask_opsz!GrammarTests.test_binary_mask_ops"  s    r7   c                     d}d}d}d S )Nr/   r   rW   rQ   r2   s     r5   test_shift_opszGrammarTests.test_shift_ops'  s    r7   c                     d}d}d}d}d S )NrW   r/   r  rQ   r2   s     r5   test_additive_opszGrammarTests.test_additive_ops,  s    r7   c                     d}d}d}d}d S )NrW         ?r   g        rQ   r2   s     r5   test_multiplicative_opsz$GrammarTests.test_multiplicative_ops2  s    r7   c                     d}d}d}d}d}d S )NrW   r  r  rQ   r2   s     r5   test_unary_opszGrammarTests.test_unary_ops8  s    #!r7   c                    dd l }dd l}|j        d         }|                                }|j        d                                         }d}|d         }|d         }|dd         }|d d         }|dd          }|d d          }|dd          }|d d         }|dd         }i }d	|d	<   d
|d<   d|d<   d|d<   t	          |          }|                    d            |                     t          |          d           d S )Nr   r  01234r  r   rW   r/   r  rX  r   rY  r  c                 .    t          |           j        | fS r   )rF   r   r   s    r5   r  z-GrammarTests.test_selectors.<locals>.<lambda>Z  s    d1gg.2 r7   r  z[1, (1,), (1, 2), (1, 2, 3)])rJ   r  r  modulesr   sortr1   r   )	r3   rJ   r  rZ  r4   r   rN   r  Ls	            r5   test_selectorszGrammarTests.test_selectors?  s/    	HQKIIKKK$$&&aDbEacFbqbEabbEaaaDbccFcrcFbeH !"#%GG	22333Q!?@@@@@r7   c                     d}d}dddf}g }dg}dg}dddg}g }i }ddi}ddi}ddi}ddd}ddd}dddddd	d
}dh}ddh}h d}h d}|}d}d}d S )NrW   r/   rX  r   rg  )r   rg  rY  r   rz  )r   rg  threefourfivesix>   r   rg  r
  >   r/   rX  rY  r4   r,  rQ   r2   s     r5   
test_atomszGrammarTests.test_atoms]  s     !QCM!QAJAKQ$a  a!!a!Q!LLGAK###JJr7   c                 <    G d d          } G d d          } G d d|          } G d d|          } G d	 d
|||          } G d d          }d  G d d                      } G d d                      }x}	 G d d                      }
fd G d d                      }ddgd          G d d                      }                       G d d                      }gd         j         j          G d d                       }d S )!Nc                       e Zd ZdS )%GrammarTests.test_classdef.<locals>.BNr  rQ   r7   r5   r  r    r  r7   r  c                       e Zd ZdS )&GrammarTests.test_classdef.<locals>.B2Nr  rQ   r7   r5   B2r    r  r7   r  c                       e Zd ZdS )&GrammarTests.test_classdef.<locals>.C1Nr  rQ   r7   r5   C1r    r  r7   r  c                       e Zd ZdS )&GrammarTests.test_classdef.<locals>.C2Nr  rQ   r7   r5   C2r    r  r7   r  c                       e Zd ZdS )%GrammarTests.test_classdef.<locals>.DNr  rQ   r7   r5   r  r    r  r7   r  c                        e Zd Zd Zd Zd ZdS )%GrammarTests.test_classdef.<locals>.Cc                     d S r   rQ   r\   s    r5   meth1z+GrammarTests.test_classdef.<locals>.C.meth1  r   r7   c                     d S r   rQ   )r3   args     r5   meth2z+GrammarTests.test_classdef.<locals>.C.meth2  r   r7   c                     d S r   rQ   )r3   rl  ro  s      r5   meth3z+GrammarTests.test_classdef.<locals>.C.meth3  r   r7   N)r   r   r   r   r#  r%  rQ   r7   r5   r   r    s+        !!!&&&)))))r7   r   c                     | S r   rQ   r   s    r5   class_decoratorz3GrammarTests.test_classdef.<locals>.class_decorator  s    qr7   c                       e Zd ZdS )%GrammarTests.test_classdef.<locals>.GNr  rQ   r7   r5   Gr)            r7   r*  Fc                       e Zd ZdS )%GrammarTests.test_classdef.<locals>.HNr  rQ   r7   r5   Hr-    r+  r7   r.  c                       e Zd ZdS )%GrammarTests.test_classdef.<locals>.INr  rQ   r7   r5   Ir0    r+  r7   r1  c                      |           S r   rQ   )rZ  r'  s    r5   r  z,GrammarTests.test_classdef.<locals>.<lambda>  s    ??1%% r7   c                       e Zd ZdS )%GrammarTests.test_classdef.<locals>.JNr  rQ   r7   r5   Jr4    r+  r7   r5  .rW   c                       e Zd ZdS )%GrammarTests.test_classdef.<locals>.KNr  rQ   r7   r5   Kr7    r+  r7   r8  c                       e Zd ZdS )%GrammarTests.test_classdef.<locals>.LNr  rQ   r7   r5   r  r:    r+  r7   r  r   c                       e Zd ZdS )%GrammarTests.test_classdef.<locals>.MNr  rQ   r7   r5   r3  r<    r+  r7   r3  )r  )r3   r  r  r  r  r  r   r*  r.  r  r1  r5  r8  r  r3  r'  s                  @r5   test_classdefzGrammarTests.test_classdef  s        B   	* 	* 	* 	* 	* 	* 	* 	* 	)((	 
 " 
"	!	 
		%	%	%	% 
&	%
	$Q	' 
(	'	)	)	)/	:	: 
;	:
	1		&	/ 
0	/r7   c                 V    g d}|                      d |D             dddd           d S )Nr  c                     i | ]}||d z   	S r  rQ   r  r  s     r5   
<dictcomp>z/GrammarTests.test_dictcomps.<locals>.<dictcomp>  s    ...A!AaC...r7   r/   rX  rY  r0   )r3   numss     r5   test_dictcompszGrammarTests.test_dictcomps  sB     yy.....A!0B0BCCCCCr7   c           	         	 g d}g dg d}                      d |D             g d                                 d |D             g d                                 d |D             g d	                                 fd
|D             g d                                 fd|D             g d                                 d t          d          D             dgddgg dg dg dg           d }                       ||          g d            fd} |             t           d           t           d           g d}g dg d		fd|D             }                      |g d           d S )Nr[  )AppleBananaCoconut)z  Applez Banana zCoco  nut  c                 6    g | ]}|                                 S rQ   )strip)r  rN   s     r5   r  z/GrammarTests.test_listcomps.<locals>.<listcomp>  s     222!''))222r7   )rE  rF  z	Coco  nutc                     g | ]}d |z  S r  rQ   r  s     r5   r  z/GrammarTests.test_listcomps.<locals>.<listcomp>  s    ...A!a%...r7   )rX  rz  r:   r     c                     g | ]
}|d k    |S r  rQ   r  s     r5   r  z/GrammarTests.test_listcomps.<locals>.<listcomp>  s    333QUU!UUUr7   r  c                 "    g | ]}D ]}||fS rQ   rQ   r  r  rN   strss      r5   r  z/GrammarTests.test_listcomps.<locals>.<listcomp>  s*    ===Q==11a&====r7   ))rW   rE  rW   rF  rW   rG  )r/   rE  r/   rF  r/   rG  )rX  rE  rX  rF  rX  rG  )rY  rE  rY  rF  rY  rG  )r   rE  r   rF  r   rG  c                 6    g | ]}d  D             D ]}||fS )c                     g | ]}d |v |	S )r  rQ   )r  r   s     r5   r  z:GrammarTests.test_listcomps.<locals>.<listcomp>.<listcomp>  s    8U8U8UqCSTHHHHHr7   rQ   rN  s      r5   r  z/GrammarTests.test_listcomps.<locals>.<listcomp>  s9    VVVQ8U8UD8U8U8UVV11a&VVVVr7   )
rP  rQ  rR  rS  rT  rU  rV  rW  rX  rY  c                 &    g | ]} d  |          S )c                 @      fdt           dz             D             S )Nc                     g | ]}|z  S rQ   rQ   )r  r  r   s     r5   r  zLGrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>.<locals>.<listcomp>  s    $>$>$>aQT$>$>$>r7   rW   ranger~  s   `r5   r  z8GrammarTests.test_listcomps.<locals>.<listcomp>.<lambda>  s&    $>$>$>$>51::$>$>$> r7   rQ   )r  r  s     r5   r  z/GrammarTests.test_listcomps.<locals>.<listcomp>  s'    UUUq>>>BBUUUr7   r   rW   )rW   r/   rY  )rW   rX  r:      )rW   rY     @      c                     d | D             S )Nc                 :    g | ]}|d k    d|cxk     odk     nc S )r/   r   rX  rQ   r  s     r5   r  zEGrammarTests.test_listcomps.<locals>.test_in_func.<locals>.<listcomp>  s1    222!AEEAIIIIAIIIIEEEr7   rQ   )ls    r5   test_in_funcz1GrammarTests.test_listcomps.<locals>.test_in_func  s    22q2222r7   )FFFc                  Z                          d dD             ddgddgddgg           d S )	Nc                 0    g | ]}d  ||dz   fD             S )c                     g | ]}|S rQ   rQ   r  r   s     r5   r  zUGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>.<listcomp>  s    555Qq555r7   rW   rQ   r  s     r5   r  zJGrammarTests.test_listcomps.<locals>.test_nested_front.<locals>.<listcomp>  s/    GGG!551a!e*555GGGr7   )rW   rX  r   rW   r/   rX  rY  r   rz  r0   r\   s   r5   test_nested_frontz6GrammarTests.test_listcomps.<locals>.test_nested_front  sL    GGwGGG !fq!fq!f57 7 7 7 7r7   z"[i, s for i in nums for s in strs]z[x if y]))rW   Boeing)r/   Ford)rX  
Macdonalds))r  Airliner)r  Engine)   Cheeseburger))rW   r  )rW   r  )r/   r  )rX  rs  c                 V    g | ]%\  }}D ]\  }}D ]\  }}||k    ||k    ||f&S rQ   rQ   )	r  snosnamepnopnamesp_snosp_pnopartssupparts	          r5   r  z/GrammarTests.test_listcomps.<locals>.<listcomp>  sl     
 
 
e"'
 
 3(/	
 
 %VVF]]sf}}	 %. (5}}}}r7   ))rn  rq  )rn  rr  )ro  rr  )rp  rt  )r1   r`  r   )
r3   rB  spcsrh  rm  	suppliersr4   r|  rO  r}  s
   `      @@@r5   test_listcompszGrammarTests.test_listcomps  s   ---55522T2224T4T4TUUU.....0A0A0ABBB33T333YYY???====$===G G G	H 	H 	H 	VVVV$VVV9 9 9	: 	: 	: 	UUERSHHUUU#1vyyy---ATATATU	W 	W 	W	3 	3 	3 	d++-B-B-BCCC	7 	7 	7 	7 	7 	4!EFFF4,,,
 
 
	
 
 

 
 

 
 
 
 
 )
 
 
 	 = = = 	> 	> 	> 	> 	>r7   c           
      >	   d t          d          D             }|                     t          |          d t          d          D                        	 t          |           |                     d           n# t          $ r Y nw xY wd	 fdD             }t          |           |                     d           n# t
          $ r Y nw xY w|                     t          d d	D                       d
 d	D                        |                     t          d dD                       d dD                        d t          d          D             d d D             D             }|                     t          |          t          d t          d          D                                  |                     t          d t          d          D                       t          d t          d          D                                  |                     t          d t          d          D                       t          d t          d          D                                  |                     t          d d t          d          D             D                       t          d t          d          D                                  |                     t          d d d t          d          D             D             D                       t          d t          d          D                                  |                     t          d d d t          d          D             D             D                       t          d  t          d          D                                  |                     t          d! d" d# t          d          D             D             D                       t          d$ t          d          D                                  |                     t          d% d& d' t          d          D             D             D                       d(           t          | d)           t          | d*           d S )+Nc              3   H   K   | ]}d  t          d          D             V  dS )c                     g | ]}|S rQ   rQ   r  s     r5   r  z7GrammarTests.test_genexps.<locals>.<genexpr>.<listcomp>  s    ###Aa###r7   r  Nr_  r  s     r5   	<genexpr>z,GrammarTests.test_genexps.<locals>.<genexpr>  s7      66##r###666666r7   rW   c                     g | ]}|S rQ   rQ   r  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  s    "8"8"81"8"8"8r7   r  z&should produce StopIteration exceptionc              3      K   | ]}V  d S r   rQ   )r  r  r   s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s      qr7   zshould produce TypeErrorc              3   (   K   | ]}d D ]}||fV  	dS )r\  NrQ   r  r4   r   s      r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s3      EEfEEq!fEEEEEEEr7   r\  c                      g | ]}d D ]}||fS )r\  rQ   r  s      r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  s,    GoGoGoSThnGoGocdAGoGoGoGor7   c              3   (   K   | ]}d D ]}||fV  	dS )xyNrQ   r  s      r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s3      AADAAqq!fAAAAAAAr7   abc                      g | ]}d D ]}||fS )r  rQ   r  s      r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  s+    CgCgCgqbfCgCg]^QFCgCgCgCgr7   c                     g | ]}|S rQ   rQ   r  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  s    """1Q"""r7   c              3      K   | ]}|V  d S r   rQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s"      ''1Q''''''r7   c              3      K   | ]}|V  d S r   rQ   rl  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s      qr7   c                     g | ]}|S rQ   rQ   r  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  s    %;%;%;Aa%;%;%;r7   c              3       K   | ]	}|d z  V  
dS r/   NrQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>   s&      55aQT555555r7   c                     g | ]}|d z  S r  rQ   r  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>   s    ;T;T;TQAqD;T;T;Tr7   c              3   *   K   | ]}|d z  ||z  V  dS r  rQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s/      ;;Qqs;QqS;;;;;;r7   c                 "    g | ]}|d z  ||z  S r  rQ   r  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  s(    A`A`A`!\]^_\_A`!A#A`A`A`r7   c              3      K   | ]}|V  d S r   rQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s"      ??1Q??????r7   c              3      K   | ]}|V  d S r   rQ   rl  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s"      (>(>q(>(>(>(>(>(>r7   c                     g | ]}|S rQ   rQ   r  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  s    E[E[E[AaE[E[E[r7   c              3      K   | ]}|V  d S r   rQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  "      LL1QLLLLLLr7   c              3      K   | ]}|V  d S r   rQ   rl  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s"      (K(Kq(K(K(K(K(K(Kr7   c              3      K   | ]}|V  d S r   rQ   r  r   s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  "      4J4J1Q4J4J4J4J4J4Jr7   c                     g | ]}|S rQ   rQ   r  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>      RhRhRhYZSTRhRhRhr7   c              3      K   | ]}|V  d S r   rQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  r  r7   c                     g | ]}|S rQ   rQ   rl  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  s    (K(K(Kq(K(K(Kr7   c              3      K   | ]}|V  d S r   rQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  r  r7   c                     g | ]}|S rQ   rQ   r  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  r  r7   c              3      K   | ]}|V  dS TNrQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s"      \\1Q\\\\\\r7   c              3      K   | ]}|V  d S r   rQ   rl  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s"      (S(Sq(S(S(S(S(S(Sr7   c              3      K   | ]}|V  dS r  rQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  "      4R4R1Q4R4R4R4R4R4Rr7   c                     g | ]}|S rQ   rQ   r  s     r5   r  z-GrammarTests.test_genexps.<locals>.<listcomp>  s    bxbxbxijcdbxbxbxr7   c              3      K   | ]}|V  dS r  rQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s"      ee1Qeeeeeer7   c              3      K   | ]}dS )FNrQ   rl  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  s      (\(\q(\(\(\r7   c              3      K   | ]}|V  dS r  rQ   r  s     r5   r  z,GrammarTests.test_genexps.<locals>.<genexpr>  r  r7   r   zfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r`  r1   nextrM   StopIterationr  r   sumr   )r3   r  r   r   s      @r5   test_genexpszGrammarTests.test_genexps  s   66U1XX666a"8"8eBii"8"8"8999	GGGII>???? 	 	 	D	 	AAGGGII01111 	 	 	D	 	EEfEEEEEGoGoX^GoGoGopppAAdAAAAACgCgTXCgCgCghhh""b		"""''A'''Q%;%;r%;%;%;!<!<===5559955555s;T;T%PR));T;T;T7U7UVVV;;%));;;;;SA`A`uUWyyA`A`A`=a=abbb??(>(>E"II(>(>(>?????E[E[QVWYQZQZE[E[E[A\A\]]]LL(K(K4J4Jb		4J4J4J(K(K(KLLLLLcRhRh^cdf^g^gRhRhRhNiNijjjLL(K(K4J4Jb		4J4J4J(K(K(KLLLLLcRhRh^cdf^g^gRhRhRhNiNijjj\\(S(S4R4Rb		4R4R4R(S(S(S\\\\\^abxbxnstvnwnwbxbxbx^y^yzzzee(\(\4R4Rb		4R4R4R(\(\(\eeeeeghiii4!ABBB4!ABBBBBs$   $A; ;
BB2C 
CCc                    dd t                    D             }d|                     t          t          |                    d           ddfdt                    D             }dd|                     d t          d          D             t          |                     |                     d t          d          D             g d	           |                     t          d
 t          d          D                       g d	           |                     d dD             g d           |                     t          d dD                       g d           d S )Nr  c              3      K   | ]}|V  d S r   rQ   r@  s     r5   r  z;GrammarTests.test_comprehension_specials.<locals>.<genexpr>  s"      ))1Q))))))r7   r   Fc              3   H   K   | ]}t                    D ]}||fV  	d S r   r_  )r  r  r  tr4   s      r5   r  z;GrammarTests.test_comprehension_specials.<locals>.<genexpr>  s?      OO!1OeAhhOO1OOOOOOOr7   Tc                 :    g | ]}t          d           D ]}||fS r   r_  )r  r  r  s      r5   r  z<GrammarTests.test_comprehension_specials.<locals>.<listcomp>  s/    EEEAE!HHEEq1Q%EEEEr7   c                 &    g | ]}|d z  |dz  |S r  rQ   r  s     r5   r  z<GrammarTests.test_comprehension_specials.<locals>.<listcomp>  s*    CCC1q5CAEC1CCCr7   )rW   r   r{  c              3   .   K   | ]}|d z  |dz  |V  dS )r/   rX  NrQ   r  s     r5   r  z;GrammarTests.test_comprehension_specials.<locals>.<genexpr>  s4      EEAa!eEq1uEaEEEEEEr7   c                     g | ]\  }|S rQ   rQ   r  s     r5   r  z<GrammarTests.test_comprehension_specials.<locals>.<listcomp>  s    999!999r7   ))rY  r  )rz  r  c              3      K   | ]\  }|V  	d S r   rQ   r  s     r5   r  z;GrammarTests.test_comprehension_specials.<locals>.<genexpr>  s$      ==BAa======r7   ))r{  )r|  )r:   )r{  r|  r:   )r`  r1   r   r   )r3   r  r  r4   s     @@r5   test_comprehension_specialsz(GrammarTests.test_comprehension_specials
  s{   ))a)))q1T!WWr*** EOOOOOuQxxOOO14qEErEEEtAwwOOO 	CCeBiiCCCYYYOOOEErEEEEEyyyQQQ 	99&8999999EEE==*<=====yyyIIIIIr7   c                     G d dt                     } |            5  	 d d d            n# 1 swxY w Y    |            5 }	 d d d            n# 1 swxY w Y    |            5 \  }}	 d d d            n# 1 swxY w Y    |            5   |            5  	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y    |            5 } |            5 }	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y    |            5 } |            5  	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y    |            5  	 d d d            n# 1 swxY w Y    |            5 }	 d d d            n# 1 swxY w Y    |            5 \  }} |            5 }	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y    |            5   |            5  	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y    |            5 } |            5 }	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y    |            5 } |            5  	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y    |            5 } |            5 } |            5 }	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y    |            5 } |            5 } |            5  	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                       e Zd Zd Zd ZdS )1GrammarTests.test_with_statement.<locals>.managerc                     dS Nr   rQ   r\   s    r5   	__enter__z;GrammarTests.test_with_statement.<locals>.manager.__enter__  s    vr7   c                     d S r   rQ   )r3   rn  s     r5   __exit__z:GrammarTests.test_with_statement.<locals>.manager.__exit__!  r  r7   N)r   r   r   r  r  rQ   r7   r5   managerr    s2              r7   r  )object)r3   r  r4   r   r   s        r5   test_with_statementz GrammarTests.test_with_statement  s	   	 	 	 	 	f 	 	 	 WYY 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	WYY 	!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	WYY 	&1a	 	 	 	 	 	 	 	 	 	 	 	 	 	 	WYY 	 			 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	WYY 	!WWYY 	!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	WYY 	!WWYY 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GII		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GII	!QGII			 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GII	 	GII	 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GII	GII			 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GII	GII	 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GII	GII	GII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GII	GII	GII	 	
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s  ,00AAA$A55A9<A9
B:B#B:#B'	'B:*B'	+B::B>B>C?C(C?(C,	,C?/C,	0C??DDED-!E-D1	1E4D1	5EEEE''E+.E+<F

FFG-F;/G;F?	?GF?	GGG'H2H 4H H	HH	HHH,I7I9II			II		II #I 1J!<J
>J!
J	J!J	J!!J%(J%6LK1KK1KK1!K"K1%L1K5	5L8K5	9LLLM0(M3M5MMMM	MM0M	M0M	 M00M47M4c                 4   d }|                      d d d fD             dg           |                      d d d fD             dg           |                      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 S )Nc                 $    t          |            |S )z@helper to check that evaluation of expressions is done correctlyr   )re  rets     r5   
_checkevalz2GrammarTests.test_if_else_expr.<locals>._checkevalc  s    #JJJJr7   c                 6    g | ]} |             |            S rQ   rQ   r  s     r5   r  z2GrammarTests.test_if_else_expr.<locals>.<listcomp>j  s)    NNN1N1133NNNr7   c                      dS )NTrQ   rQ   r7   r5   r  z0GrammarTests.test_if_else_expr.<locals>.<lambda>j  s     r7   c                      dS NFrQ   rQ   r7   r5   r  z0GrammarTests.test_if_else_expr.<locals>.<lambda>j  s    u r7   Tc                 :    g | ]} |d            |d           S r   rQ   r  s     r5   r  z2GrammarTests.test_if_else_expr.<locals>.<listcomp>k  s2    {{{qrqrsxqyqy{11U88{{{r7   c                     | rdndS )NFTrQ   r   s    r5   r  z0GrammarTests.test_if_else_expr.<locals>.<lambda>k  s    8L r7   c                     | rdndS )NTFrQ   r   s    r5   r  z0GrammarTests.test_if_else_expr.<locals>.<lambda>k  s    `aXlX\X\gl r7   rW   r   zcheck 1r   zcheck 2rz  zcheck 3r/   rX  zcheck 4zcheck 5zcheck 6Fr{  r  rY  g      @r0   )r3   r  s     r5   test_if_else_exprzGrammarTests.test_if_else_expra  s   	 	 	 	NN}}(ENNNQUPVWWW{{.L.LNlNl-m{{{  C  ~D  	E  	E  	E!CCCQCCCA222a!444!444!aHHH!]^___qaHHH%e444!a000%a000%a000%b111%a000!a00000r7   c                 4   |                      dd           |                      dd           |                      dd           d}d}|                     d||u u            |                     d|u |u            |                     d|cxu o|u nc            d S )Nr|  r/   rX  F)r1   rK   assertFalser   s      r5   test_paren_evaluationz"GrammarTests.test_paren_evaluation|  s    ++++++q)))!q&)***%1**+++!q)))))r7   c                      G d d          } |            }|                      ||z  d           |dz  }|                      |j        d           d S )Nc                       e Zd Zd Zd ZdS )'GrammarTests.test_matrix_mul.<locals>.Mc                     dS )NrY  rQ   r3   r.  s     r5   
__matmul__z2GrammarTests.test_matrix_mul.<locals>.M.__matmul__  s    qr7   c                     || _         | S r   )otherr  s     r5   __imatmul__z3GrammarTests.test_matrix_mul.<locals>.M.__imatmul__  s    
r7   N)r   r   r   r  r  rQ   r7   r5   r3  r    s2              r7   r3  rY  r   )r1   r  )r3   r3  ms      r5   test_matrix_mulzGrammarTests.test_matrix_mul  sx    	 	 	 	 	 	 	 	 ACCQ"""	R"%%%%%r7   c                    d }|                      |j        d           |                     t          |j        j        t          j        z                       d }|d             }|                     |j                   |                      |j        d           |                     t          |j        j        t          j        z                       d S )Nc                  :   K   d } 	 t                       d {V  d S )Nc                      d S r   rQ   rQ   r7   r5   r  z8GrammarTests.test_async_await.<locals>.test.<locals>.sum  r  r7   )someobj)r  s    r5   r   z+GrammarTests.test_async_await.<locals>.test  s3         iir7   r   c                 (    t          | dd           | S )N_markedT)setattr)funcs    r5   	decoratorz0GrammarTests.test_async_await.<locals>.decorator  s    D)T***Kr7   c                  
   K   dS )N   rQ   rQ   r7   r5   test2z,GrammarTests.test_async_await.<locals>.test2  s      2r7   r  )	r1   r   rK   boolr  co_flagsinspectCO_COROUTINEr  )r3   r   r  r  s       r5   test_async_awaitzGrammarTests.test_async_await  s    	  	  	  	///T]3g6JJKKLLL	 	 	 
	 	 
	&&&111U^4w7KKLLMMMMMr7   c                      G d dt                      G d d          fd}|                               5   |                                d            d d d            d S # 1 swxY w Y   d S )Nc                       e Zd ZdS ))GrammarTests.test_async_for.<locals>.DoneNr  rQ   r7   r5   Doner    r  r7   r  c                       e Zd Zd Zd ZdS )*GrammarTests.test_async_for.<locals>.AIterc                     | S r   rQ   r\   s    r5   	__aiter__z4GrammarTests.test_async_for.<locals>.AIter.__aiter__  s    r7   c                    K   t           r   )StopAsyncIterationr\   s    r5   	__anext__z4GrammarTests.test_async_for.<locals>.AIter.__anext__  s      ((r7   N)r   r   r   r  r  rQ   r7   r5   AIterr    s2          ) ) ) ) )r7   r  c                     K                2 3 d {V } 6              2 3 d {V \  } }6              2 3 d {V } 6 	 r   rQ   )r  r  r  r  s     r5   rK  z(GrammarTests.test_async_for.<locals>.foo  s       577       a ##egg       da & 577       a # Js   ,?r   rG   send)r3   rK  r  r  s     @@r5   test_async_forzGrammarTests.test_async_for  s    #####9###	) 	) 	) 	) 	) 	) 	) 	)		 		 		 		 		 		 t$$ 	 	CEEJJt	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   A))A-0A-c                      G d dt                      G d d          fd}|                               5   |                                d            d d d            d S # 1 swxY w Y   d S )Nc                       e Zd ZdS )*GrammarTests.test_async_with.<locals>.DoneNr  rQ   r7   r5   r  r    r  r7   r  c                       e Zd Zd Zd ZdS )-GrammarTests.test_async_with.<locals>.managerc                 
   K   dS r  rQ   r\   s    r5   
__aenter__z8GrammarTests.test_async_with.<locals>.manager.__aenter__  s      vr7   c                 
   K   dS r  rQ   )r3   excs     r5   	__aexit__z7GrammarTests.test_async_with.<locals>.manager.__aexit__  s      ur7   N)r   r   r   r  r  rQ   r7   r5   r  r	    s2              r7   r  c                    K                4 d {V  	 d d d           d {V  n# 1 d {V swxY w Y                4 d {V } 	 d d d           d {V  n# 1 d {V swxY w Y                4 d {V \  } }	 d d d           d {V  n# 1 d {V swxY w Y                4 d {V               4 d {V  	 d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  n# 1 d {V swxY w Y                4 d {V }              4 d {V }	 d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  n# 1 d {V swxY w Y                4 d {V }              4 d {V  	 d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  n# 1 d {V swxY w Y   r   rQ   )r4   r   r  r  s     r5   rK  z)GrammarTests.test_async_with.<locals>.foo  s     wyy                                  wyy       A                          wyy       FQ                          wyy        ''))                                                             wyy       Awwyy       A                                                     wyy       Awwyy                                                             Js   (
22	A
A'*A'>B
B"B6C>C	C>
C%	%C>(C%	)C>>
DDE'0E2E'
E	E'E	E''
E14E1GF-G-
F7	7G:F7	;G
GGr  )r3   rK  r  r  s     @@r5   test_async_withzGrammarTests.test_async_with  s    #####9###	 	 	 	 	 	 	 		 	 	 	 	 	 t$$ 	 	CEEJJt	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  N)Mr   r   r   r   r   r   r   r   r   r   r   r   r  r)  r4  r;  r@  rM  rU  r]  r  rH  rL  rP  rY  r]  r_  ra  rf  rm  ru  rz  r|  r  r  r  r  r  r  r  r  r  r  unittest
skipUnlessr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r=  rC  r  r  r  r  r  r  r  r  r  r  rQ   r7   r5   r   r   A  s       //////AAAAAA>>>>>>  
& 
& 
&1 1 1(, , ,\0 0 0,< < <: : :	% 	% 	%# # #A A A*A A A"3 3 3v& v& v&p!) !) !)N  2 2 2% % %.W W W4      4  47 7 72# 2# 2#h3# 3# 3#j" " ",3 3 38/ / /4%; %; %;N3 3 36' ' '& & &I I I  2 2 2& X$FGGE E HGEA A A@ @ @*    ( ( (BX X X2G G G0  	9 	9 	9K K K"6 6 6"PB PB PBd  
  
    " " "A A A<  F  BD D D=> => =>~!C !C !CFJ J J&B B BH1 1 16* * *& & &N N N*  .    r7   r   __main__)r   r   r   r   r   r  r  rJ   rX   test.ann_moduler/  r0  collectionsr	   r   r
   rb   rd   TestCaser-   r   r   r   r   r   mainrQ   r7   r5   <module>r     s   , + + + + + + & & & & & & = = = = = =   



      % $ $ $ $ $                       .4 4 4 nJA JA JA JA JA" JA JA JAX           X X X X X8$ X X Xv4 zHMOOOOO r7   