
    0hh{                    r   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SKrS SKrS SKJr  S SKJr   S SKrS SKJr  S SKJr  S SKJrJr  S SKJr  S SKJr  S S	KJrJrJ r J!r!J"r"J#r#   " S
 S\
RH                  5      r% " S S\
RH                  5      r& " S S\
RH                  5      r' " S S\
RH                  5      r( " S S\
RH                  5      r) " S S\
RH                  5      r* " S S5      r+ " S S\+\
RH                  5      r, " S S\\+\
RH                  5      r- " S S\
RH                  5      r.\R^                   " S S\
RH                  5      5       r0 " S  S!\
RH                  5      r1S" r2 " S# S$\
RH                  5      r3\4S%:X  a  \
Rj                  " 5         gg! \ a    Sr GNof = f)&    N)partial)dedent)support)import_fresh_module)	os_helperscript_helper)ASTTestMixin)to_tuple)
eval_testseval_results
exec_testsexec_resultssingle_testssingle_resultsc                      \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)\*RV                  S( 5       r,S) r-S* r.S+ r/S, r0S- r1S. r2S/ r3S0 r4S1 r5S2 r6S3 r7S4 r8S5 r9\*RV                  S6 5       r:S7 r;S8\<\=R|                     S9\?S:\?S;S4S< jr@S?S= jrAS>rBg)@	AST_Tests    Nc                     [        U[        5      (       d  gSUR                  ;  a  gUS:g  =(       a    US   R                  5       $ )NFastASTr   )
isinstancetype
__module__isupper)selfnamenodes      ?/opt/python-3.13.8/usr/lib/python3.13/test/test_ast/test_ast.py_is_ast_nodeAST_Tests._is_ast_node#   s;    $%%'u}2a!22    c                    [        U[        R                  5      (       a  UR                  c  g [        U[        R                  [        R
                  [        R                  45      (       aA  UR                  UR                  4nU R                  X25        UR                  UR                  4nUR                   H  n[        X5      n[        U[        5      (       aI  UnU(       a$  US:X  a  US   R                  US   R                  4nU H  nU R                  Xv5        M     Ml  Uc  Mq  U R                  XR5        M     U R                  UR                  UR                  5        g )Ndecorator_listr   )r   r   r   _fieldsexprstmtexcepthandlerlineno
col_offsetassertGreaterEqualgetattrlist_assertTrueorderassertEqual__match_args__)r   ast_node
parent_posnode_posr   value	first_poschilds           r   r-   AST_Tests._assertTrueorder*   s   (CGG,,0@0@0Hh388S5F5F GHH )<)<=H##H9"//8+>+>?J$$DH+E%&&&	T%55!&q%(2E2E FI"E))%; #"%%e8 % 	))8+B+BCr!   c                    [         R                  " 5       nU R                  UR                  S5        SUl        U R                  UR                  S5        U R                  UR
                  S   S5        U R                  [        5         UR                    S S S 5        U R                  [        5         [         R                  " S5        S S S 5        g ! , (       d  f       NC= f! , (       d  f       g = f)N *   foobar   )
r   r   r.   r$   r:   __dict__assertRaisesAttributeErrorvararg	TypeErrorr   xs     r   test_AST_objectsAST_Tests.test_AST_objects=   s    GGIB'2&H-r2~.HH / y)GGAJ *) /. *)s   	C3C$
C!$
C2c                   ^ [         R                  R                  mU4S jnU R                  U5        [         R                  ?SnU R	                  [
        U5         [         R                  " SS9  S S S 5        U R	                  [
        U5         [         R                  " 5         S S S 5        g ! , (       d  f       NC= f! , (       d  f       g = f)Nc                  0   > T [         R                  l        g N)r   r   r$   )	old_values   r   cleanup5AST_Tests.test_AST_fields_NULL_check.<locals>.cleanupO   s    'CGGOr!   z0type object 'ast.AST' has no attribute '_fields'{   )arg1)r   r   r$   
addCleanupassertRaisesRegexr>   )r   rI   msgrH   s      @r   test_AST_fields_NULL_check$AST_Tests.test_AST_fields_NULL_checkK   s    GGOO		( GGO@##NC8GG 9##NC8GGI 98 9888s   B-B>-
B;>
Cc                     " S S5      n[         R                  " 5       nU" 5       Ul        X"R                  l        [        R
                  " UR                  5      nA[        R                  " 5         U R                  U" 5       5        g )Nc                       \ rS rSrSrg)0AST_Tests.test_AST_garbage_collection.<locals>.X]   r8   N__name__r   __qualname____firstlineno____static_attributes__r8   r!   r   XrT   ]       r!   r[   )	r   r   rB   aweakrefrefr   
gc_collectassertIsNone)r   r[   r]   r_   s       r   test_AST_garbage_collection%AST_Tests.test_AST_garbage_collection\   s\    	 	 GGIckk!###% r!   c           	         [         [        S4[        [        S4[        [
        S44 H  u  pn[        X5       H  u  pEU R                  SUS9   [        USU[        R                  5      nU R                  [        U5      U5        U R                  US5        S S S 5        U R                  SXCS	9   [        WSU5        S S S 5        M     M     g ! , (       d  f       N== f! , (       d  f       M  = f)
Nexecsingleevalparsing)actioninput?)r   r   	compiling)ri   rj   kind)r   r   r   r   r   r   zipsubTestcompiler   PyCF_ONLY_ASTr.   r
   r-   )r   rj   outputrm   ioast_trees          r   test_snippetsAST_Tests.test_snippetsh   s    v.>84v.$
E4
 E*\\!\<&q#tS5F5FGH$$Xh%7;))(F; = \\A\IHc40 JI +$
 =< JIs   A
C/C
C
C.c                     [         [        -   [        -   nU H&  n[        R                  " U5      n[        USS5        M(     g )N<string>re   )r   r   r   r   parserp   )r   snippets_to_validatesnippettrees       r   test_ast_validationAST_Tests.test_ast_validationv   s6    )L8:E+G99W%DD*f- ,r!   c                 @   / SQnU GH  u  p#U R                  X#S9   [        R                  " SUS9n[        R                  " [        R                  " S5      US9nXE4 GH  nU R                  UR                  S   [        R
                  5        [        U[        5      (       al  U R                  UR                  S   R                  [        R                  5        U R                  UR                  S   R                  R                  U5        M  U R                  UR                  S   R                  [        R                  5        U R                  UR                  S   R                  R                  U5        GM     S S S 5        GM     g ! , (       d  f       GM  = f)N))	__debug__)r   r   )   F)r;   F)optvalexpectedr   optimizer   )ro   r   rz   assertIsInstancebodyExprr   boolr3   Constantr.   Nameid)r   casesr   r   res1res2ress          r   !test_optimization_levels__debug__+AST_Tests.test_optimization_levels__debug__}   s   M %FV?yyv>yy;!7&I <C))#((1+sxx@!(D11--chhqk.?.?N((!):):)@)@(K--chhqk.?.?J((!):):)=)=xH ( @? !&??s   E#F
F	c                 t   SnSnSU4SU4SU4SU4/nU H  u  pEU R                  US9   [        R                  " SUS	9n[        R                  " [        R                  " S5      US	9nXg4 H,  n[        UR                  S   5      n	U R                  X5        M.     S S S 5        M     g ! , (       d  f       M  = f)
N)r   r   r   r      )r   r      N)r   r   )BinOpr   )r   )r   r   r   r   r   N)Add)r   )r      r   r   r;   Nr   r   r   r;   )r   1 + 2r   )ro   r   rz   r
   r   r.   )
r   folded
not_foldedr   r   r   tree1tree2r}   r   s
             r   &test_optimization_levels_const_folding0AST_Tests.test_optimization_levels_const_folding   s    L


 j!Az?QK!VM %FV,		'F;		#))G"4vF"ND"499Q<0C$$S3 + -, !&,,s   A2B((
B7	c                    / SQnU H  u  p#U R                  SU SU 35         Sn[        R                  " U5      nX%R                  S   l        X5R                  S   l        U R                  [        5         [        USS5        S S S 5        S S S 5        M     / SQnU H  u  pxU R                  SU SU 35         Sn[        R                  " U5      nXuR                  S   l	        XR                  S   l
        U R                  [        5         [        USS5        S S S 5        S S S 5        M     g ! , (       d  f       N= f! , (       d  f       GML  = f! , (       d  f       N?= f! , (       d  f       M  = f)	N))
   r   )i)r   r   ))r   r   zCheck invalid linenos :za = 1r   ry   re   zCheck invalid col_offset )ro   r   rz   r   r(   
end_linenor=   
ValueErrorrp   r)   end_col_offset)	r   invalid_linenosr(   r   r|   r}   invalid_col_offsetsr)   r   s	            r   !test_invalid_position_information+AST_Tests.test_invalid_position_information   s9   M"1F 6vha
|LM!yy)&,		!#*4		!'&&z2D*f5 3 NM #2 R*=&J+J<q8HI "yy)*4		!'.<		!+&&z2D*f5 3  +>	 32 NM" 32 sI   AE7D2E;AE'EE'2
E <E
E	
E$ E''
E6	c                     [         R                  " [         R                  " [         R                  " SSSS9/SSS9[         R                  " [         R                  " SSSS9/SSS9// S9n[	        USS	5        g )
Nbuiltinsr   r   r   r(   r)   )namesr(   r)   	tracebackr   type_ignoresry   re   )r   ModuleImportaliasrp   r   r}   s     r   >test_compilation_of_ast_nodes_with_default_end_position_valuesHAST_Tests.test_compilation_of_ast_nodes_with_default_end_position_values   st    zz

99*Q1MN 
 

99+aANO  
" 	j&)r!   c           	      X   [         R                  " SSSS9nSSS.SSS.SSSS.SSSS.4 Hj  nU R                  US9   [         R                  " [         R                  " SS	U/0UD6// S
9n[        USS5        [         R                  " USS9  S S S 5        Ml     g ! , (       d  f       M~  = f)Nr   r   r   r   r(   r)   )r(   r)   r   )r(   r   r)   )attrsr   r   ry   re   r;   r   r8   )r   r   ro   r   r   rp   rz   )r   r   r   r}   s       r   #test_negative_locations_for_compile-AST_Tests.test_negative_locations_for_compile   s    		{1C++bA1=	
E E*zzJJ6eW66( "$
 j&1 		$+ +*
 +*s   AB
B)	c                    [         R                  " S5      R                  S   R                  R                  nU R                  UR                  5        U R                  UR                  5        U R                  UR                  5        g )Nzx[::]r   )	r   rz   r   r3   slicera   upperlowerstep)r   slcs     r   
test_sliceAST_Tests.test_slice   s]    ii %%a(..44#))$#))$#((#r!   c                     [         R                  " S5      R                  S   nU R                  UR                  5        g )Nzfrom . import yr   )r   rz   r   ra   module)r   ims     r   test_from_importAST_Tests.test_from_import   s.    YY()..q1"))$r!   c                     [         R                  " S5      nU R                  UR                  S   [         R                  5        SR                  5       UR                  S   l        [        USS5        g )Nzfrom __future__ import divisionr   z __future__ <test>re   )r   rz   r   r   
ImportFromstripr   rp   )r   mods     r   !test_non_interned_future_from_ast+AST_Tests.test_non_interned_future_from_ast   sR    ii9:chhqk3>>:+113Xv&r!   c                    [         R                  " S5      R                  S   nU R                  [	        UR
                  5      S5        UR
                  S   nU R                  UR                  S5        U R                  UR                  5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        [         R                  " S5      R                  S   nUR
                  S   nU R                  UR                  S5        U R                  UR                  5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        [         R                  " S	5      R                  S   nUR
                  S   nU R                  UR                  S5        U R                  UR                  S
5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        [         R                  " S5      R                  S   nUR
                  S   nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        g )Nzfrom bar import yr   r   y      zfrom bar import **zfrom bar import y as zz   zimport bar as foobarfoo   )r   rz   r   r.   lenr   r   ra   asnamer(   r   r)   r   )r   r   r   s      r   
test_aliasAST_Tests.test_alias   s   YY*+003RXX*S)%,,'q)))1-))2.--r2YY*+003S)%,,'q)))1-))2.--r2YY/055a8S)s+q)))1-))2.--r2YY*+003U+u-q)))1-))1---r2r!   c                    U R                  [        [        R                  [        R                  5      5        U R                  [        [        R
                  [        R                  5      5        U R                  [        [        R                  [        R                  5      5        U R                  [        [        R                  [        R                  5      5        U R                  [        [        R                  [        R                  5      5        U R                  [        [        R                  [        R                  5      5        g rG   )

assertTrue
issubclassr   Forr&   r   r%   r   comprehensionGtr   s    r   test_base_classesAST_Tests.test_base_classes  s    
377CHH56
388SXX67
388SWW56
388SWW56
3#4#4cgg>?
36637734r!   c                     [        S5      nSnS H<  nU R                  [        UR                  U5      5         [	        X5        S S S 5        M>     g ! , (       d  f       MP  = f)Nr   zSast\.{} is deprecated and will be removed in Python 3.14; use ast\.Constant insteadNumStrBytesNameConstantEllipsis)r   assertWarnsRegexDeprecationWarningformatr+   )r   r   
depr_regexr   s       r   test_import_deprecated AST_Tests.test_import_deprecated!  sX    !%() 	 FD&&'9:;L;LT;RS" TS FSSs   A
A 	c                 n   [         R                  " 5          [         R                  " SS[        5        SSKJnJnJnJnJ	n  S S S 5        S H  n[        [        U5      nU R                  Xg5      (       d  M+  U R                  U5         U R                  [        5         U" 5       nS S S 5        S S S 5        [        W[        R                  5      (       d  M  U R!                  [#        UR$                  5      [&        5        M     g ! , (       d  f       N= f! , (       d  f       Nv= f! , (       d  f       N= f)Nignore r   r   )warningscatch_warningsfilterwarningsr   r   r   r   r   r   r   r+   r   ro   assertWarnsr   r   assertIsr   r$   tuple)	r   r   r   r   r   r   r   itemrB   s	            r   $test_field_attr_existence_deprecated.AST_Tests.test_field_attr_existence_deprecated+  s    $$&##Hb2DECC ' HD3%D  ,,\\$'))*<= F > ( a))MM$qyy/59 H	 '& >= ('s/   +DD&D%D&
D
D#D&&
D4	c                 X   [         R                  R                  5        H  u  pUS;   a  M  US:X  a  M  U R                  X5      (       d  M-  U R	                  U5      n[        U[         R                  5      (       d  M_  U R                  [        UR                  5      [        5        M     g )N>   r   r   r   r   r   Index)r   r<   itemsr   _construct_ast_classr   r   r  r   r$   r  )r   r   r  rB   s       r   test_field_attr_existence#AST_Tests.test_field_attr_existence9  sy    ,,,,.JDJJw  ,,--d3a))MM$qyy/59 /r!   c                 L   0 nUR                   R                  5        H}  u  p4U[        L a  SX#'   M  U[        L a  SX#'   M#  U[        L a  SX#'   M2  [        U[        5      (       d  MI  [        U[        R                  5      (       d  Mj  U R                  U5      X#'   M     U" S0 UD6$ )Ncapybarar9   s   capybarar8   )__annotations__r  strintobjectr   r   r   r   r   r	  )r   clskwargsr   typs        r   r	  AST_Tests._construct_ast_classF  s    ,,224IDcz)!*C&&:c377+C+C#88= 5 }V}r!   c                    [         R                  " 5       nU R                  UR                  S5        U R                  UR                  [
        [         R                     [
        [         R                     [         R                  S -  [
        [         R                     [
        [         R                     [         R                  S -  [
        [         R                     S.5        U R                  UR                  / 5        U R                  UR                  5        [         R                  " [        SS5      6 nU R                  UR                  S5        U R                  UR                  S5        g )N)posonlyargsargsr?   
kwonlyargskw_defaultskwargdefaultsr      r;   r   )r   	argumentsr.   r$   r  r,   argr%   r  ra   r?   rangerA   s     r   test_argumentsAST_Tests.test_argumentsS  s    MMOII	
 	#CGG}SWW''D."377m#CHH~4 N	
 	$!((#MM5A;'#1%r!   c                 
   [         R                  " 5          [         R                  " SS[        5        [        R
                  " 5       nS S S 5        SWl        U R                  UR                  S5        g ! , (       d  f       N2= f)Nr   r     )r   r   r   r   r   r   r$   r.   rA   s     r   #test_field_attr_writable_deprecated-AST_Tests.test_field_attr_writable_deprecatedu  sW    $$&##Hb2DE	A ' 	C( '&s   2A44
Bc                 v    [         R                  " S5      nSUl        U R                  UR                  S5        g )Nr   r$  )r   r   r$   r.   rA   s     r   test_field_attr_writable"AST_Tests.test_field_attr_writable}  s*    LLO	C(r!   c           
      
   [         R                  " 5          [         R                  " SS[        5        SSKJnJnJnJnJ	n  S S S 5        [         R                  " SS9 n[         R                  " SS[        5        [        R
                  " 5       nU R                  UR                  S5        U R                  [        5         UR                    S S S 5        U R                  [        5         UR                    S S S 5        [        R
                  " S	5      nU R                  UR                  S	5        U R                  UR                  S	5        U R                  [        5         UR                     S S S 5        U R                  [        5         UR"                    S S S 5        [        R
                  " S
S9nU R                  UR                   S
5        [        R
                  " S	SS9nU R                  UR                   S5        U R                  UR                  S5        U R                  UR                  S	5        U R                  UR                  S	5        U R                  [$        [        R
                  SS S
5        U R                  [$        [        R
                  SS S
SS9  U R                  [        R
                  " SSS9R&                  S5        U R)                  [$        S5         [        R
                  " SS
S9  S S S 5        U R                  [        R
                  " S	5      R                  S	5        U R                  [        R
                  " S5      R                  S5        U R                  [        R
                  " S5      R                  S5        U R                  [        R                  " S5      R*                  S5        U R                  [        R                  " S5      R*                  S5        U R-                  [        R                  " S5      R                  S5        U R-                  [        R                  " S5      R                  S5        U R-                  [        R                  " S 5      R                  S 5        S S S 5        U R                  W Vs/ s H  n[/        UR0                  5      PM     sn/ SQ5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN}= f! , (       d  f       GN*= f! , (       d  f       N= fs  snf )Nr   r   r   r   Trecordalwaysr3   rm   r9   r;   r(   r   r   r   z(Num got multiple values for argument 'n'n      @              @42   42F)Rast.Num is deprecated and will be removed in Python 3.14; use ast.Constant insteadlConstant.__init__ missing 1 required positional argument: 'value'. This will become an error in Python 3.15.OAttribute n is deprecated and will be removed in Python 3.14; use value insteadr7  r9  r7  r8  r7  r9  r7  r7  r7  zConstant.__init__ got an unexpected keyword argument 'foo'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15.r7  r9  r7  r9  r7  r9  Rast.Str is deprecated and will be removed in Python 3.14; use ast.Constant insteadOAttribute s is deprecated and will be removed in Python 3.14; use value insteadTast.Bytes is deprecated and will be removed in Python 3.14; use ast.Constant insteadr;  [ast.NameConstant is deprecated and will be removed in Python 3.14; use ast.Constant insteadr=  r=  )r   r   r   r   r   r   r   r   r   r   r.   r$   r=   r>   r3   r2  r(   r:   r@   r   rN   sr  r  message)	r   r   r   r   r   r   wlogrB   ws	            r   test_classattrs_deprecated$AST_Tests.test_classattrs_deprecated  s   $$&##Hb2DECC ' $$D1T##Hb2DE	AQYY(9:"">2 3 "">2 3 AQWWb)QSS"%"">2 3 "">2 3 q!AQXXq)1%AQXXq)QYY(9:QWWb)QSS"%i!T1=i!T1QG SWWQE266>''E Q
 SWWR[]]B/SWWT]__d3SWWU^--u5SWWT]__d3SYYu-//7MM#**4066=MM#**5177?MM#**4066=a 2d 	%)*TS^T*"	
m '& 32 32 32 32$ I 21f +s   +SA#T3 ST3*S+7A+T3"S=/T3TET3(T!>FT3U
S
S(	#T3+
S:	5T3=
T	T3
T	T3!
T0	+T33
Uc           	      
	   U R                  [        5         [        R                  " 5       nS S S 5        U R	                  WR
                  S5        U R                  [        5         UR                    S S S 5        [        R                  " S5      nU R	                  UR                  S5        U R                  [        5         UR                    S S S 5        U R                  [        5         UR                    S S S 5        [        R                  " SSS9nU R	                  UR                  S5        [        R                  " SSS9nU R	                  UR                  S5        U R	                  UR
                  S5        U R	                  UR                  S5        U R                  [        [        R                  SS S5        U R                  [        [        R                  SS SSS9  U R                  [        5         U R	                  [        R                  " SS	S
9R                  S	5        S S S 5        U R                  [        S5         [        R                  " SSS9  S S S 5        U R	                  [        R                  " S5      R                  S5        U R	                  [        R                  " S5      R                  S5        U R	                  [        R                  " S5      R                  S5        U R	                  [        R                  " S5      R                  S5        U R	                  [        R                  " S5      R                  S5        U R                  [        R                  " S5      R                  S5        U R                  [        R                  " S5      R                  S5        U R                  [        R                  " S 5      R                  S 5        U R                  [        R                  " S5      R                  S5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNv= f! , (       d  f       GN^= f! , (       d  f       GN<= f! , (       d  f       GN= f)Nr.  r9   r;   r   )r(   r3   r   r/  r   r   r0  z1Constant got multiple values for argument 'value'r3   r3  r4  r5  r6  TF.)r   r   r   r   r.   r$   r=   r>   r3   r(   r:   r@   r   rN   r  rA   s     r   test_classattrsAST_Tests.test_classattrs  s   01A 2$56~.GG / LL"%~.HH / ~.HH / LL+1%LLA&1%$56"%)S\\1dA>)S\\1dAaH 01S\\!7;;UC 2 ##J
 LL!$

 	b)//4d+1148e,22E:d+1148e,22E:cll4(..5cll5)//7cll4(..5cll3'--s3Y 21 /. /. /. 21
 
sG   P%P+P=+Q<0Q!
Q3
P(+
P:=
Q
Q!
Q03
Rc                    [         R                  " 5          [         R                  " SS[        5        SSKJnJnJnJnJ	n  S S S 5        [         R                  " SS9 n[         R                  " SS[        5        U R                  [        [        R
                  " S5      5      [        R                  5        U R                  [        [        R
                  " S	5      5      [        R                  5        U R                  [        [        R
                  " S
5      5      [        R                  5        U R                  [        [        R                  " S5      5      [        R                  5        U R                  [        [        R                  " S5      5      [        R                  5        U R                  [        [        R                  " S5      5      [        R                  5        U R                  [        [        R                  " S5      5      [        R                  5        U R                  [        [        R                  " S 5      5      [        R                  5        U R                  [        [        R                  " 5       5      [        R                  5        S S S 5        U R                  W Vs/ s H  n[        UR                  5      PM     sn/ SQ5        g ! , (       d  f       GN= f! , (       d  f       NY= fs  snf )Nr   r   r   r   Tr+  r-  r9   r3  r4  r5  r6  F)	r7  r7  r7  r:  r<  r=  r=  r=  zWast.Ellipsis is deprecated and will be removed in Python 3.14; use ast.Constant instead)r   r   r   r   r   r   r   r   r   r   r  r   r   r.   r  r?  )r   r   r   r   r   r   r@  rA  s           r   test_realtypeAST_Tests.test_realtype  s   $$&##Hb2DECC ' $$D1T##Hb2DEMM$swwr{+S\\:MM$swwt}-s||<MM$swwu~.=MM$swwt}-s||<MM$syy/0#,,?MM$s//56EMM$s//67FMM$s//56EMM$s||~.= 2 	%)*TS^T*
	
! '& 21 +s   +KIK15L
K.1
K?c                    SSK Jn  [        R                  " 5          [        R                  " SS[
        5        SSK JnJnJnJ	nJ
n  S S S 5        Sn[        U R                  [
        UR                  S5      5      n[        U R                  [
        UR                  S5      5      n	[        U R                  [
        UR                  S	5      5      n
[        U R                  [
        UR                  S
5      5      n[        U R                  [
        UR                  S5      5      nS HU  nU R                  US9   U" 5          W" U5      nS S S 5        U" 5          U R                  WW5        S S S 5        S S S 5        MW     U	" 5          W" S5      nS S S 5        U	" 5          U R                  WW5        S S S 5        U
" 5          W" S5      nS S S 5        U
" 5          U R                  WW5        S S S 5        S HU  nU R                  US9   U" 5          W" U5      nS S S 5        U" 5          U R                  WW5        S S S 5        S S S 5        MW     U" 5          W" 5       nS S S 5        U" 5          U R                  WW5        S S S 5        S HC  nU R                  US9   U" 5          U R                  U" U5      W5        S S S 5        S S S 5        ME     U	" 5          U R                  U" S5      W5        S S S 5        U
" 5          U R                  U" S5      W5        S S S 5        S HC  nU R                  US9   U" 5          U R                  U" U5      W5        S S S 5        S S S 5        ME     U" 5          U R                  U" S5      W5        S S S 5        U	" 5          W" S5      nS S S 5        U" U R                   WW5        U
" U R                   UW5        U" 5          U" S5      nS S S 5        U	" U R                   WW5        U" U R                   UW5        U" U R                   UW5        U" 5          U" S5      nS S S 5        U" 5          U R!                  X5        S S S 5        U" 5          U" S5      nS S S 5        U" 5          U R!                  X5        S S S 5        S HC  nU R                  US9   U" 5          U R!                  U" U5      U5        S S S 5        S S S 5        ME     U	" U R                   U" S5      U5        U
" U R                   U" S5      U5        U" U R                   U" S5      U5        U" U R                   U" S5      U5        U" U R                   U" S 5      U5        U	" U R                   U" S 5      U5        U
" U R                   U" S 5      U5        U" U R                   U" S5      U5        U" U R                   U" S 5      U5         " S S["        5      nU	" 5          U R                  U" U" S5      5      U5        S S S 5        U" 5          U R!                  U" U" S5      5      U5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GMV  = f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GM  = f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNm= f! , (       d  f       GM  = f! , (       d  f       GN^= f! , (       d  f       GNH= f! , (       d  f       GN= f! , (       d  f       GMk  = f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNt= f! , (       d  f       GNI= f! , (       d  f       GM  = f! , (       d  f       GN;= f! , (       d  f       g = f)Nr   )r   r   r   r   zQast.{} is deprecated and will be removed in Python 3.14; use ast.Constant insteadr   r   r   r   r   )r9   g@y        @)r  r5  r6  TFN.r9   TF)r5  TFr   c                       \ rS rSrSrg)$AST_Tests.test_isinstance.<locals>.Si  r8   NrV   r8   r!   r   SrN    r\   r!   rO  )r   r   r   r   r   r   r   r   r   r   r   r   r   r   ro   r   assertNotIsInstancer  )r   r   r   r   r   r   r   cls_depr_msgassertNumDeprecatedassertStrDeprecatedassertBytesDeprecatedassertNameConstantDeprecatedassertEllipsisDeprecatedr  r2  r>  berO  s                      r   test_isinstanceAST_Tests.test_isinstance-  s^    $$&##Hb2DECC '
' 	
 &!!#5|7J7J57Q
 &!!#5|7J7J57Q
 !(!!#5|7J7J77S!
 (/!!/(
$
 $+!!#5|7J7J:7V$
  !C#&(*CA +(*))!S1 + '& ! !"D	A # "!!!S) # #$eA %"$!!!U+ % %C#&13$S)A 413))!\: 4 '& % &'
A (%'!!!X. ( !C#&(*))(3-= + '& !
 !"!!(4.#6 # #$!!(5/59 % %C#&13))(3-F 4 '& %
 &'!!(3-: ( !"D	A #D44a=d665A "BA #D44a=$T%=%=q,O !9!91hG)+T"A , "$$Q, # *+U#A , "$$Q, # %C#&(*,,Xc]C@ + '& %
 	D44hrlCHd66N$$$hrlL	
 	!!9!98B<RD44htncJD44htncJd66N$$$hqk<	
 	!!9!98D>8T	 	 !"!!(1T7"3S9 # "$$Xag%6< #"q '&: +*** '& #""" %$$$
 4333 '& ('''
 +* '& #" %$
 43 '& (' #"
 #" ,+"" ,+""
 +* '&* #"""s  +X57Y+?	YY+Y*Y+	Y>Z?	Z"Z4[*	[[*&[9[*[=+\\3"\!;\3]>]3]<;]*]</^	^!	^3+	__$	_)<_;*`2```2a5
Y
YY+
Y(#Y++
Y;	>
Z
Z"
Z14
[
[[*
['"[**
[:	=
\
\!
\0+\33
]	
]
]'*
]94]<<
^	
^!
^03
_
_
_&)
_8;
`

``
`/	2
a
ac                    [         R                  " 5          [         R                  " SS[        5        SSKJn  S S S 5        [         R                  " SS9 n[         R                  " SS[        5         " S S	[        R
                  5      n " S
 S[        R
                  5      nU" S5      nU R                  UR                  S5        U R                  UR                  S5        U R                  [        U5      U5        U R                  XS5        U R                  U[        R
                  5        U R                  XT5        U R                  [        R
                  " S5      U5        U" SS9nU R                  UR                  S5        U R                  [        U5      U5        S S S 5        U R                  W Vs/ s H  n[        UR                  5      PM     sn/ SQ5        g ! , (       d  f       GN= f! , (       d  f       NY= fs  snf )Nr   r   r   r   Tr+  r-  c                   (   ^  \ rS rSrU 4S jrSrU =r$ )8AST_Tests.test_constant_subclasses_deprecated.<locals>.Ni  c                 4   > [         TU ]  " U0 UD6  SU l        g Nspamsuper__init__r   r   r  r  	__class__s      r   rd  AAST_Tests.test_constant_subclasses_deprecated.<locals>.N.__init__  s    G$d5f5#DFr!   r   rW   r   rX   rY   rd  rZ   __classcell__rf  s   @r   Nr^    s    $ $r!   rl  c                       \ rS rSrSrg)9AST_Tests.test_constant_subclasses_deprecated.<locals>.N2i  r8   NrV   r8   r!   r   N2rn        r!   ro  r9   ra  r1  )r9  r9  r7  r7  r9  r9  )r   r   r   r   r   r   r.   r2  r   r  r   r   rP  r  r?  )r   r   r@  rl  ro  r2  rA  s          r   #test_constant_subclasses_deprecated-AST_Tests.test_constant_subclasses_deprecated  st   $$&##Hb2DE ' $$D1T##Hb2DE$CGG $
SWW  "AQSS"%QSS&)MM$q'1%!!!'!!!SWW-$$Q+$$SWWR[!4BAQSS"%MM$q'1%+ 2. 	%)*TS^T*
	
7 '& 210 +s   #G%EG7;H%
G47
Hc                     " S S[         R                  5      n " S S[         R                  5      nU" S5      nU R                  UR                  S5        U R                  UR                  S5        U R                  [        U5      U5        U R                  [        X15      5        U R                  [        U[         R                  5      5        U R                  [        X25      5        U R                  [        [         R                  " S5      U5      5        U" SS9nU R                  UR                  S5        U R                  [        U5      U5        g )Nc                   (   ^  \ rS rSrU 4S jrSrU =r$ )-AST_Tests.test_constant_subclasses.<locals>.Ni  c                 4   > [         TU ]  " U0 UD6  SU l        g r`  rb  re  s      r   rd  6AST_Tests.test_constant_subclasses.<locals>.N.__init__  s     $1&1r!   rh  ri  rk  s   @r   rl  ru    s       r!   rl  c                       \ rS rSrSrg).AST_Tests.test_constant_subclasses.<locals>.N2i  r8   NrV   r8   r!   r   ro  ry    r\   r!   ro  r9   ra  rE  )	r   r   r.   r3   r   r   r   r   assertFalse)r   rl  ro  r2  s       r   test_constant_subclasses"AST_Tests.test_constant_subclasses  s    	  	 
	 	 bE"%f%a!$
1()
1cll34A*+CLL$4a89BK"%a!$r!   c                     [         R                  " S5      /n[         R                  " U/ 5      nU R                  UR                  U5        g )Nr9   )r   r   r   r.   r   )r   r   rB   s      r   test_moduleAST_Tests.test_module  s7    R !JJtR &r!   c           
         U R                  [        5         [        R                  " 5       nS S S 5        U R	                  WR
                  S5        SUl        U R	                  UR                  S5        [        R                  " S5      n[        R                  " S5      n[        R                  " 5       n[        R                  " X$U5      nU R	                  UR                  U5        U R	                  UR                  U5        U R	                  UR                  U5        [        R                  " SSS5      nU R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        [        R                  " SSSSS9nU R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R                  [        [        R                  SSSS5        U R                  [        [        R                  SSSSSS9  [        R                  " SSSSS	9nU R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R                  [        5         [        R                  " SSSS
S9nS S S 5        U R	                  UR                  S
5        g ! , (       d  f       GN= f! , (       d  f       N== f)Nleftoprightr   r   r   r;   r   r/  r   )r  r  r  r(   r9   )	foobarbaz)r   r   r   r   r.   r$   r  r   r   r  r  r  r(   r=   r@   )r   rB   n1n3addops        r   test_nodeclassesAST_Tests.test_nodeclasses  sm   01		A 2$;< a(\\!_\\!_	IIb$$u%"%IIaA#q!!$IIaAa(#q!!$1% 	)SYY1a;)SYY1a1E II1!A6#q!!$1% 01		!QR0A 2b)U 21P 21s   L:=M:
M	
Mc                 f    [         R                  " 5       nU R                  UR                  S5        g )Nr8   )r   Subr.   r$   rA   s     r   test_no_fieldsAST_Tests.test_no_fields  s!    GGIB'r!   c           	      \   [        SSS9n[        R                  " [        R                  " [        R                  " S0 UD640 UD6// 5      nU R                  [        5       n[        USS5        S S S 5        U R                  S[        WR                  5      5        g ! , (       d  f       N4= f)Nr;   r   r   r   re   zbut got <ast.exprr8   )dictr   r   r   r%   r=   r@   rp   assertInr  	exception)r   posmcms       r   test_invalid_sumAST_Tests.test_invalid_sum   s{    !*JJC8C892>y)RAx( *)3r||+<= *)s   !B
B+c           	         [         R                  " [         R                  " [         R                  " S[         R                  " 5       5      5      // 5      n[         R
                  " U5        U R                  [        5       n[        USS5        S S S 5        U R                  S[        WR                  5      5        g ! , (       d  f       N4= f)Nr9   r   re   zidentifier must be of type str)r   r   r   r   Loadfix_missing_locationsr=   r@   rp   r  r  r  )r   r  r  s      r   test_invalid_identifier!AST_Tests.test_invalid_identifier'  s    JJ"chhj!9:;R@!!!$y)RAx( *6BLL8IJ *)s    B<<
C
c                 J   [         SS[         4[        SS[         45      4 Hm  n[        R                  " [        R                  " U5      S9n[        R
                  " U5        U R                  [        S5         [        USS5        S S S 5        Mo     g ! , (       d  f       M  = f)Nr   r;   r   zinvalid type in Constant: typer   rg   )	r  	frozensetr   
Expressionr   r  rN   r@   rp   )r   invalid_constantrX  s      r   test_invalid_constantAST_Tests.test_invalid_constant.  s|     #aC[)Q3K2H HCLL1A$BCA%%a(''	3ST8V, UT !I UTs   8B
B"	c                 H   [         R                  " S5      nS UR                  S   R                  S   R                  l        U R	                  [
        5       n[        USS5        S S S 5        U R                  S[        WR                  5      5        g ! , (       d  f       N4= f)Nzdef f():
 yield from g()r   r   re   zfield 'value' is required)
r   rz   r   r3   r=   r   rp   r  r  r  )r   empty_yield_fromr  s      r   test_empty_yield_fromAST_Tests.test_empty_yield_from5  sz    99%@A7;a %%a(..4z*b$h7 +13r||3DE +*s   B
B!c                     SS K nS n[        R                  " USU5         U R                  [        [
        R                  S5        S S S 5        g ! , (       d  f       g = f)Nr   c                      g rG   r8   r  s    r   bad_normalize0AST_Tests.test_issue31592.<locals>.bad_normalizeC  s    r!   	normalizeu   ϕ)unicodedatar   	swap_attrr=   r@   r   rz   )r   r  r  s      r   test_issue31592AST_Tests.test_issue31592=  sC     		 {KGiH= HGGs   &A
Ac                    [         R                  " S5      nUR                  S   R                  nUR                  nUR                  nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        [         R                  " S5      nUR                  S   R                  nUR                  nUR                  nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S	5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S	5        U R                  UR                  S	5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        g )
Nz4+5+6+7r   r   r   r   z
4+5-\
 6-7r   r   r;   )
r   rz   r   r3   r  r.   r)   r   r(   r   )r   r}   parent_binopchild_binopgrandchild_binops        r    test_issue18374_binop_col_offset*AST_Tests.test_issue18374_binop_col_offsetI  s   yy#yy|))"''&++00!444a8//333Q7)44a8)88!<yy(yy|))"''&++00!4,,a044a800!4//3++Q/33Q7//3)44a8)00!4)88!<)44a8r!   c                     [         R                  " S5      nUR                  S   R                  S   R                  nU R                  UR                  S5        g )Nz@a.b.c
def f(): passr   r   )r   rz   r   r#   r3   r.   r   )r   r}   attr_bs      r   *test_issue39579_dotted_name_end_col_offset4AST_Tests.test_issue39579_dotted_name_end_col_offseth  sE    yy011,,Q/55..2r!   c                    U R                  [        R                  R                  S5        U R                  [        R                  R                  S5        U R                  [        R
                  R                  S5        U R                  [        R                  R                  S5        [        R                  R                  5        Vs/ s H  nSUR                   3PM     nnS[        R                  R                  5       S   R                   3US'   U R                  [        R                  R                  R                  S5      U5        g s  snf )	Nz0withitem(expr context_expr, expr? optional_vars)GtEz%Name(identifier id, expr_context ctx)zBcmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotInz     | zexpr = r   
)r.   r   withitem__doc__r  r   cmpopr%   __subclasses__assertCountEqualsplit)r   r   expressionss      r   test_ast_asdl_signature!AST_Tests.test_ast_asdl_signaturem  s    LL  "T	
 	%0))+RSIIP	
 =@HH<S<S<UV<UD/<UV"388#:#:#<Q#?#G#G"HIAchh..44T:KH Ws   	Ec                    [         R                  " SSS9  [         R                  " SSS9  U R                  [        5         [         R                  " SSS9  S S S 5        U R                  [        5         [         R                  " SSS9  S S S 5        [         R                  " SSS9  [         R                  " SSS9  U R                  [        5         [         R                  " SSS9  S S S 5        U R                  [        5         [         R                  " SSS9  S S S 5        g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Nd= f! , (       d  f       g = f)Nzdef foo(x, /): ...r   r  feature_versionzdef bar(x=1, /): ...r   r   zlambda x, /: ...zlambda x=1, /: ...r   rz   r=   SyntaxErrorr   s    r   $test_positional_only_feature_version.AST_Tests.test_positional_only_feature_version{  s    		&?		(&A{+II*FC ,{+II,fE , 			$f=		&?{+II(&A ,{+II*FC ,+ ,+++
 ,+++s0    D"3D3EE"
D03
E
E
E#c                     [         R                  " SSS9  U R                  [        5         [         R                  " SSS9  S S S 5        g ! , (       d  f       g = f)Nz(x := 0)r  r  r  r  r   s    r   *test_assignment_expression_feature_version4AST_Tests.test_assignment_expression_feature_version  s8    		*f5{+IIj&9 ,++s   A


Ac                 .    [         R                  " SSS9  g )Nzwith (x() if y else z()): ...r  r  r   rz   r   s    r   @test_conditional_context_managers_parse_with_low_feature_versionJAST_Tests.test_conditional_context_managers_parse_with_low_feature_version  s    		16Jr!   c                     [        S5      n[        R                  " U5        U R                  [        5         [        R                  " USS9  S S S 5        g ! , (       d  f       g = f)Nz9
        try: ...
        except* Exception: ...
        )r   r   r  )r   r   rz   r=   r  )r   codes     r   %test_exception_groups_feature_version/AST_Tests.test_exception_groups_feature_version  sF       			${+IIdG4 ,++s   A
A$c                 *   / SQnU Hf  nU R                  U5         [        R                  " U5        U R                  [        5         [        R                  " USS9  S S S 5        S S S 5        Mh     g ! , (       d  f       N= f! , (       d  f       M  = f)N)ztype X = intzclass X[T]: passzdef f[T](): pass)r      r  ro   r   rz   r=   r  r   samplessamples      r    test_type_params_feature_version*AST_Tests.test_type_params_feature_version  h    

 Ff%		&!&&{3IIfg> 4 &%  43 &%#   ,BA2B2
B <B
B	c                 *   / SQnU Hf  nU R                  U5         [        R                  " U5        U R                  [        5         [        R                  " USS9  S S S 5        S S S 5        Mh     g ! , (       d  f       N= f! , (       d  f       M  = f)N)ztype X[*Ts=int] = intzclass X[T=int]: passzdef f[**P=int](): pass)r      r  r  r  s      r   (test_type_params_default_feature_version2AST_Tests.test_type_params_default_feature_version  r  r  c                    U R                  [        5         [        R                  " SSS9  S S S 5        U R                  [        5         [        R                  " SSS9  S S S 5        g ! , (       d  f       NB= f! , (       d  f       g = f)Npass)r;   r   r  )r   r   )r=   r   r   rz   r   s    r   "test_invalid_major_feature_version,AST_Tests.test_invalid_major_feature_version  sW    z*IIff5 +z*IIff5 +* +***s   A(	A9(
A69
Bc                 B   S H  n[         R                  " [         R                  " U[         R                  " 5       5      5      n[         R                  " U5        U R                  [        SU S35         [        USS5        S S S 5        M     g ! , (       d  f       M  = f)N)TrueFalseNone"identifier field can't represent '
' constantr   rg   )r   r  r   r  r  rN   r   rp   )r   constantr%   s      r   test_constant_as_nameAST_Tests.test_constant_as_name  sy    /H>>#((8SXXZ"@AD%%d+''@
*U h/  0 s   4B
B	c                     / SQnU HA  nU R                  [        SUS    S35         [        R                  " US   SS9  S S S 5        MC     g ! , (       d  f       MU  = f)N))r  s   Truᵉ)r  s   Falſe)r  s   Nºner  r   r  r   rg   mode)rN   r   r   rz   )r   	constantsr  s      r   test_constant_as_unicode_name'AST_Tests.test_constant_as_unicode_name  sa    
	
 "H''
4Xa[MLN		(1+F3N N "N Ns   A
A	c                      " S S[         R                  5      n[         R                  " U[        R                  5        g )Nc                      \ rS rSrSr\R                  " 5       r\R                  " 5       r\R                  " 5       r	\R                  " 5       r
\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       rS rSrg)3AST_Tests.test_precedence_enum.<locals>._Precedencei  z5Precedence table that originated from python grammar.c                 P     U R                  U S-   5      $ ! [         a    U s $ f = f)Nr   )rf  r   r   s    r   next8AST_Tests.test_precedence_enum.<locals>._Precedence.next  s.     >>$(33!  K s    %%r8   N)rW   r   rX   rY   r  enumauto
NAMED_EXPRTUPLEYIELDTESTORANDNOTCMPEXPRBORBXORBANDSHIFTARITHTERMFACTORPOWERAWAITATOMr  rZ   r8   r!   r   _Precedencer    s    GJIIKEIIKE99;DB))+C))+C))+C99;DC99;D99;DIIKEIIKE99;DYY[FIIKEIIKE99;D r!   r  )r  IntEnum_test_simple_enumr   r  )r   r  s     r   test_precedence_enumAST_Tests.test_precedence_enum  s(    	 $,, 	 < 	{COO<r!   c                 &  ^ ^^^ [         R                  " 5       mSm[        [         R                  " 5       S-  5      m[        b!  [        R
                  " 5       n[        TU5      mUUU U4S jnU" SS5        U" SS5        U" SS5        U" SS5        g )	Ni g?c                 p  > XT	-  -   n[         R                  " U5        TT4 Hm  nXU-  -   nSR                  XU5      nTR                  [        US9   [
        R                  " 5          [         R                  " U5        S S S 5        S S S 5        Mo     g ! , (       d  f       N= f! , (       d  f       M  = f)NzCompiling ({!r} + {!r} * {})rO   )r   rz   r   r=   RecursionErrorr   infinite_recursion)
prefixrepeated	expect_okdepthbrokendetailscrash_depth
fail_depthr   success_depths
         r   check_limit7AST_Tests.test_ast_recursion_limit.<locals>.check_limit  s    M!99IIIi $k2U"228??RWX&&~7&C 335		&) 6 DC 3 65 DCs$   B&)B B&
B#B&&
B5	r]   ()z.bz[0]z*a)r   exceeds_recursion_limitr  get_c_recursion_limit_testinternalcapiget_c_recursion_remainingmin)r   	remainingr+  r(  r)  r*  s   `  @@@r   test_ast_recursion_limit"AST_Tests.test_ast_recursion_limit  s    446
G99;cAB()CCEIy9M	* 	* 	CCCCr!   c                     U R                  [        SS9   [        R                  " S5        S S S 5        g ! , (       d  f       g = f)Nz,source code string cannot contain null bytesr  za b)r=   r  r   rz   r   s    r   test_null_bytesAST_Tests.test_null_bytes  s9    K  
 IIf
 
 
s	   5
Ar   attrsourcereturnc                    U R                  UR                   SU 35         [        R                  " U5      nSn[        R                  " U5       H&  n[        Xa5      (       d  M  [        XbS 5        US-  nM(     U R                  US5        [        R                  " SU SUR                   35      nU R                  [        SU S35         [        USS	5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)
N.r   r   zfield 'z' is required for ^$r   re   )ro   rW   r   rz   walkr   setattrr.   reescaperN   r   rp   )r   r   r9  r:  r}   foundr5   rX  s           r   assert_none_checkAST_Tests.assert_none_check  s    \\T]]O1TF3499V$DE$e**E.QJE ( UA&		GD6);DMM?KLA''
as!H=h/ > 54 >= 54s+   A C<%A'C<C+C<+
C9	5C<<
D
c           	      @   [         R                  SS4[         R                  SS4[         R                  SS4[         R                  SS4[         R                  S	S
4[         R
                  SS4[         R                  SS4/nU H  u  p#nU R                  X#U5        M     g )Nr   zimport spam as SPAMr  zdef spam(SPAM): spamtargetz[spam for SPAM in spam]iterz[spam for spam in SPAM]r3   zspam(**SPAM)patternzmatch spam:
 case SPAM: spamcontext_exprzwith SPAM: spam)r   r   r  r   keyword
match_caser  rE  )r   testsr   r9  r:  s        r   test_none_checksAST_Tests.test_none_checks  s    YY 56WWe34*CD(AB[['>2^^Y(GH\\>+<=
 #(D""4v6 #(r!   r8   )r;  N)CrW   r   rX   rY   maxDiffr   r-   rC   rP   rb   rv   r~   r   r   r   r   r   r   r   r   r   r   r   r  r
  r	  r!  r%  r(  rB  rF  rI  rY  rq  r{  r~  r  r  r  r  r  r  r   cpython_onlyr  r  r  r  r  r  r  r  r  r  r  r  r  r  r4  r7  r   r   r   r  rE  rO  rZ   r8   r!   r   r   r       s{   G3D&"
!1.I4.60*(,($%'$3L5#:: &D))Y
v-4^
@|=|&
P%*'
,*\(
>K-F 	> 	>9>3
ID:
K5
?
?60	4=B  .0d377m 03 0 0PT 07r!   r   c                   $    \ rS rSrSrS rS rSrg)	CopyTestsi(  z$Test copying and pickling AST nodes.c           	      \   SS K n[        UR                  S-   5       Hz  n[         Hm  nU R	                  X2S9   [        USSS5      nUR                  UR                  XB5      5      nU R                  [        U5      [        U5      5        S S S 5        Mo     M|     g ! , (       d  f       M  = f)Nr   r   )r  protocolrk   re   i   )
pickler   HIGHEST_PROTOCOLr   ro   rp   loadsdumpsr.   r
   )r   rW  rV  r  r}   ast2s         r   test_picklingCopyTests.test_pickling+  s    f559:H"\\t\?"4fe<D!<<T(DED$$Xd^Xd^D @? # ;??s   AB
B+c           
         Sn[         R                  " [        R                  " U5      5      n[         R                  " U5       H&  n[         R
                  " U5       H	  nX4l        M     M(      [        R                  " S5         [        R                  " U5      nS S S 5        [         R                  " U5       H  n[        US5      (       d  M  U?M     [         R                  " W5       H  n[         R
                  " U5       H  n[        US5      (       d  M  [        U[         R                  [         R                  [         R                  [         R                   [         R"                  45      (       a  Mt  U R%                  ['        UR                  5      ['        U5      5        M     M     g ! , (       d  f       GN= f! [         R                  " U5       H  n[        US5      (       d  M  U?M     f = f)Na=  
        ('',)
        while i < n:
            if ch == '':
                ch = format[i]
                if ch == '':
                    if freplace is None:
                        '' % getattr(object)
                elif ch == '':
                    if zreplace is None:
                        if hasattr:
                            offset = object.utcoffset()
                            if offset is not None:
                                if offset.days < 0:
                                    offset = -offset
                                h = divmod(timedelta(hours=0))
                                if u:
                                    zreplace = '' % (sign,)
                                elif s:
                                    zreplace = '' % (sign,)
                                else:
                                    zreplace = '' % (sign,)
                elif ch == '':
                    if Zreplace is None:
                        Zreplace = ''
                        if hasattr(object):
                            s = object.tzname()
                            if s is not None:
                                Zreplace = s.replace('')
                    newformat.append(Zreplace)
                else:
                    push('')
            else:
                push(ch)

           parent)r   rz   textwrapr   r@  iter_child_nodesr`  r   r!  copydeepcopyhasattrr   expr_contextboolopunaryopr  operatorr.   r
   )r   r  r}   r   r5   r   s         r   test_copy_with_parents CopyTests.test_copy_with_parents5  sY   #H yy./HHTND--d3# 4 #	$++C0d+ 1
 4** ' HHUOD--d35(++J((

			5 	5 $$Xell%;Xd^L 4 $ 10
 4** 's*   .G F/G /
F>9G )G5.G5r8   N)rW   r   rX   rY   r  r\  rj  rZ   r8   r!   r   rT  rT  (  s    .E@Mr!   rT  c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"g)!ASTHelpers_Testix  Nc                     [         R                  " S5      n[        SSS[         R                  5      nU R	                  [         R
                  " U5      [         R
                  " U5      5        g )Nz
foo(1 + 1)z	<unknown>re   )r   rz   rp   rq   r.   dump)r   r]   rW  s      r   
test_parseASTHelpers_Test.test_parse{  sF    IIl#L+vs7H7HI!chhqk2r!   c                     SS-    g ! [          an    U R                  [        5       n[        R                  " S5        S S S 5        O! , (       d  f       O= fU R                  WR                  R                  5         g f = f)Nr   r   z'\U')	Exceptionr=   r  r   literal_evalassertIsNotNoner  __context__r   rX  s     r   test_parse_in_error#ASTHelpers_Test.test_parse_in_error  s_    	:E 	:"";/1  ) 0//  !8!89	:s%    B A	B 
A	,B ?B c                    [         R                  " S5      nU R                  [         R                  " U5      S5        U R                  [         R                  " USS9S5        U R                  [         R                  " USS9S5        g )	Nspam(eggs, "and cheese")Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), args=[Name(id='eggs', ctx=Load()), Constant(value='and cheese')]))])Fannotate_fieldszZModule([Expr(Call(Name('spam', Load()), [Name('eggs', Load()), Constant('and cheese')]))])Tinclude_attributesa  Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=4), args=[Name(id='eggs', ctx=Load(), lineno=1, col_offset=5, end_lineno=1, end_col_offset=9), Constant(value='and cheese', lineno=1, col_offset=11, end_lineno=1, end_col_offset=23)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=24), lineno=1, col_offset=0, end_lineno=1, end_col_offset=24)])r   rz   r.   ro  r   r   s     r   	test_dumpASTHelpers_Test.test_dump  sw    yy34HHTNS	

 	HHT51*	

 	HHTd3I		
r!   c                    [         R                  " S5      nU R                  [         R                  " USS9S5        U R                  [         R                  " USSS9S5        U R                  [         R                  " US	SS
9S5        g )Nr{  r   indentzModule(
   body=[
      Expr(
         value=Call(
            func=Name(id='spam', ctx=Load()),
            args=[
               Name(id='eggs', ctx=Load()),
               Constant(value='and cheese')]))])F	)r~  r  zwModule(
	[
		Expr(
			Call(
				Name('spam', Load()),
				[
					Name('eggs', Load()),
					Constant('and cheese')]))])T)r  r  ac  Module(
   body=[
      Expr(
         value=Call(
            func=Name(
               id='spam',
               ctx=Load(),
               lineno=1,
               col_offset=0,
               end_lineno=1,
               end_col_offset=4),
            args=[
               Name(
                  id='eggs',
                  ctx=Load(),
                  lineno=1,
                  col_offset=5,
                  end_lineno=1,
                  end_col_offset=9),
               Constant(
                  value='and cheese',
                  lineno=1,
                  col_offset=11,
                  end_lineno=1,
                  end_col_offset=23)],
            lineno=1,
            col_offset=0,
            end_lineno=1,
            end_col_offset=24),
         lineno=1,
         col_offset=0,
         end_lineno=1,
         end_col_offset=24)])r  r  s     r   test_dump_indent ASTHelpers_Test.test_dump_indent  s|    yy34HHT!$4	
 	HHT5>)	
 	HHTd1=!!$	
r!   c                    [         R                  " SSS9nU R                  [         R                  " U5      S5        U R                  [         R                  " USS9S5        [         R                  " [         R                  " S[         R
                  " 5       S	9SSS
9nU R                  [         R                  " U5      S5        U R                  [         R                  " USS9S5        U R                  [         R                  " USS9S5        U R                  [         R                  " USSS9S5        [         R                  " [         R                  " S[         R
                  " 5       S	9S9nU R                  [         R                  " U5      S5        U R                  [         R                  " USS9S5        [         R                  " [         R                  " S5      /S9nU R                  [         R                  " USS9S5        [         R                  " [         R                  " S5      /S9nU R                  [         R                  " USS9S5        [         R                  " [         R                  " S5      /[         R                  " S5      /S9nU R                  [         R                  " USS9S5        [         R                  " [         R                  " S5      /[         R                  " S5      /S9nU R                  [         R                  " USS9S5        [         R                  " 5       nU R                  [         R                  " USS9S5        [         R                  " S / [         R                  " S![         R                  " S 5      5      // [         R                  " S"[         R
                  " 5       S#9/5      nU R                  [         R                  " U5      S$5        U R                  [         R                  " USS9S%5        g )&Nr   r   r   zRaise()Tr  zRaise(lineno=3, col_offset=4)rX  r   ctx)excr(   r)   z#Raise(exc=Name(id='e', ctx=Load()))Fr}  zRaise(Name('e', Load()))z;Raise(exc=Name(id='e', ctx=Load()), lineno=3, col_offset=4))r~  r  z0Raise(Name('e', Load()), lineno=3, col_offset=4))causez%Raise(cause=Name(id='e', ctx=Load()))zRaise(cause=Name('e', Load()))rB   r  zarguments([], [arg('x')])r  zarguments([arg('x')])r   )r  r  z,arguments([arg('x')], kwonlyargs=[arg('y')]))r  r  z0arguments([], [arg('x')], kwonlyargs=[arg('y')])arguments()Tr]   	dataclassr  z~ClassDef(name='T', keywords=[keyword(arg='a', value=Constant(value=None))], decorator_list=[Name(id='dataclass', ctx=Load())])zRClassDef('T', [], [keyword('a', Constant(None))], [], [Name('dataclass', Load())]))r   Raiser.   ro  r   r  r  r  ClassDefrL  r   r  s     r   test_dump_incomplete$ASTHelpers_Test.test_dump_incomplete  s   yya0$3HHTd35T	
 yySXX#((*=aTUV$)NOHHT513M	
 	HHTd3I	
 	HHT5TJ>	
 yysxx3CHHJ?@$)PQHHT513S	
 }}3773<.1HHT51'	
 }}#''#,8HHT51#	
 }}#''#,SWWS\NSHHT51:	
 }}3773<.cggcl^LHHT51>	
 }}HHT51	

 ||[[cll4012XXksxxz23
 	HHTN M	
 	HHT51`	
r!   c                   ^ ^ U 4S jmU4S jnT" [         R                  " 5       SSS9  T" [         R                  " S[         R                  " 5       S9SSS9  T" [         R                  " S S	9S
S
S9  T" [         R                  " / S	9SSS9  T" [         R
                  " S S	9SSS9  T" [         R
                  " / S	9SSS9  T" [         R
                  " SS	9SSS9  U" SSSS9  U" SSSSS9  U" SSSS9  U" SSSS9  U" SSSS9  g )Nc                 N  > TR                  SS9   TR                  [        R                  " U 4SS0UD6U5        S S S 5        TR                  SS9   TR                  [        R                  " U 4SS0UD6U5        S S S 5        g ! , (       d  f       NP= f! , (       d  f       g = f)NF)
show_emptyr  T)ro   r.   r   ro  )r   emptyfullr  r   s       r   
check_node8ASTHelpers_Test.test_dump_show_empty.<locals>.check_node#  s    /  HHT>e>v> 0
 .  HHT=d=f= /. 0/
 /.s   *B*B
B
B$c                 B   > T" [         R                  " U 5      X40 UD6  g rG   r  )r  r  r  r  r  s       r   
check_text8ASTHelpers_Test.test_dump_show_empty.<locals>.check_text/  s    syy>v>r!   r  zNarguments(posonlyargs=[], args=[], kwonlyargs=[], kw_defaults=[], defaults=[]))r  r  r   r  zName(id='', ctx=Load())rE  zMatchSingleton(value=None)zMatchSingleton(value=[])zConstant(value=None)zConstant(value=[])zConstant(value='')zdef a(b: int = 0, *, c): ...zModule(body=[FunctionDef(name='a', args=arguments(args=[arg(arg='b', annotation=Name(id='int', ctx=Load()))], kwonlyargs=[arg(arg='c')], kw_defaults=[None], defaults=[Constant(value=0)]), body=[Expr(value=Constant(value=Ellipsis))])])a.  Module(body=[FunctionDef(name='a', args=arguments(posonlyargs=[], args=[arg(arg='b', annotation=Name(id='int', ctx=Load()))], kwonlyargs=[arg(arg='c')], kw_defaults=[None], defaults=[Constant(value=0)]), body=[Expr(value=Constant(value=Ellipsis))], decorator_list=[], type_params=[])], type_ignores=[])a}  Module(body=[FunctionDef(name='a', args=arguments(args=[arg(arg='b', annotation=Name(id='int', ctx=Load(), lineno=1, col_offset=9, end_lineno=1, end_col_offset=12), lineno=1, col_offset=6, end_lineno=1, end_col_offset=12)], kwonlyargs=[arg(arg='c', lineno=1, col_offset=21, end_lineno=1, end_col_offset=22)], kw_defaults=[None], defaults=[Constant(value=0, lineno=1, col_offset=15, end_lineno=1, end_col_offset=16)]), body=[Expr(value=Constant(value=Ellipsis, lineno=1, col_offset=25, end_lineno=1, end_col_offset=28), lineno=1, col_offset=25, end_lineno=1, end_col_offset=28)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=28)])a  Module(body=[FunctionDef(name='a', args=arguments(posonlyargs=[], args=[arg(arg='b', annotation=Name(id='int', ctx=Load(), lineno=1, col_offset=9, end_lineno=1, end_col_offset=12), lineno=1, col_offset=6, end_lineno=1, end_col_offset=12)], kwonlyargs=[arg(arg='c', lineno=1, col_offset=21, end_lineno=1, end_col_offset=22)], kw_defaults=[None], defaults=[Constant(value=0, lineno=1, col_offset=15, end_lineno=1, end_col_offset=16)]), body=[Expr(value=Constant(value=Ellipsis, lineno=1, col_offset=25, end_lineno=1, end_col_offset=28), lineno=1, col_offset=25, end_lineno=1, end_col_offset=28)], decorator_list=[], type_params=[], lineno=1, col_offset=0, end_lineno=1, end_col_offset=28)], type_ignores=[])T)r  r  r  r{  r|  zModule(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), args=[Name(id='eggs', ctx=Load()), Constant(value='and cheese')], keywords=[]))], type_ignores=[])zspam(eggs, text="and cheese")zModule(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), args=[Name(id='eggs', ctx=Load())], keywords=[keyword(arg='text', value=Constant(value='and cheese'))]))])zModule(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), args=[Name(id='eggs', ctx=Load())], keywords=[keyword(arg='text', value=Constant(value='and cheese'))]))], type_ignores=[])z*import _ast as ast; from module import subzModule(body=[Import(names=[alias(name='_ast', asname='ast')]), ImportFrom(module='module', names=[alias(name='sub')], level=0)])zModule(body=[Import(names=[alias(name='_ast', asname='ast')]), ImportFrom(module='module', names=[alias(name='sub')], level=0)], type_ignores=[]))r   r  r   r  MatchSingletonr   )r   r  r  s   ` @r   test_dump_show_empty$ASTHelpers_Test.test_dump_show_empty"  sZ   
		? 	MMOa	
 	HH
++*		
 	T*.-	
 	R(,+	
 	LLt$('	
 	LLr"&%	
 	LLr"&%	
 	*  B	
 	* R
 U#		
 	& X u	
 	+ ~ N	
 	8 U e	
r!   c           	         [         R                  " SSS9n[         R                  " [         R                  " S5      UR                  R
                  5      UR                  l        U R                  [         R                  " USS9S5        [         R                  " S[         R                  " 5       5      n[         R                  " S	S	S	S	US
9n[         R                  " U[         R                  " S S US95      nU R                  UR                  5        U R                  UR                  5        U R                  UR                  S	5        U R                  UR                  S	5        g )N1 + 1rg   r  r;   Tr  zExpression(body=BinOp(left=Constant(value=1, lineno=1, col_offset=0, end_lineno=1, end_col_offset=1), op=Add(), right=Constant(value=2, lineno=1, col_offset=4, end_lineno=1, end_col_offset=5), lineno=1, col_offset=0, end_lineno=1, end_col_offset=5))ra  r   )r)   r(   r   r   func)r)   r(   r  )r   rz   copy_locationr   r   r  r.   ro  r   r  Callra   r   r   r(   r)   )r   srcr  news       r   test_copy_location"ASTHelpers_Test.test_copy_location|  s    iif-**3<<?CHHNNKHHST2=	
 xx
+hhq
 SXXdQU%VW#..)#,,-Q'+r!   c                    [         R                  " S5      nUR                  R                  [         R                  " [         R
                  " [         R                  " S[         R                  " 5       5      [         R                  " S5      // 5      5      5        U R                  U[         R                  " U5      5        S U l        U R                  [         R                  " USS9S5        g )Nzwrite("spam")ra  eggsTr  aw  Module(body=[Expr(value=Call(func=Name(id='write', ctx=Load(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=5), args=[Constant(value='spam', lineno=1, col_offset=6, end_lineno=1, end_col_offset=12)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=13), lineno=1, col_offset=0, end_lineno=1, end_col_offset=13), Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=0), args=[Constant(value='eggs', lineno=1, col_offset=0, end_lineno=1, end_col_offset=0)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=0), lineno=1, col_offset=0, end_lineno=1, end_col_offset=0)]))r   rz   r   appendr   r  r   r  r   r.   r  rQ  ro  r   r  s     r   test_fix_missing_locations*ASTHelpers_Test.test_fix_missing_locations  s    ii(HHSXXchhvsxxz:S\\&=Q<RTVWX	
 	c77<=HHST2	[	
r!   c                    [         R                  " SSS9nU R                  [         R                  " USS9U5        U R                  [         R                  " USS9S5        [         R                  " SSS9nU R                  [         R                  " UR
                  SS9UR
                  5        U R                  [         R                  " USS9S5        [         R                  " [         R                  " S	[         R                  " 5       5      / / S
S9nU R                  [         R                  " U5      R                  S5        U R                  [         R                  " U5      R                  5        g )Nr  rg   r  r   r1  Tr  zExpression(body=BinOp(left=Constant(value=1, lineno=4, col_offset=0, end_lineno=4, end_col_offset=1), op=Add(), right=Constant(value=1, lineno=4, col_offset=4, end_lineno=4, end_col_offset=5), lineno=4, col_offset=0, end_lineno=4, end_col_offset=5))testr   )r  r  keywordsr(   r;   )r   rz   r.   increment_linenoro  r   r  r   r  r(   ra   r   r  s     r   test_increment_lineno%ASTHelpers_Test.test_increment_lineno  s   iif---cQ7=HHST2=	
 iif---chh!<chhGHHST2=	
 hh&#((*-BA
 	--c2991=#..s3>>?r!   c                 `   [         R                  " [        S5      SS9n[         R                  " USS9  U R	                  UR
                  S   R                  S5        U R	                  UR
                  S   R                  S	5        U R	                  UR
                  S   R                  S
5        g )Nzb        a = 1
        b = 2 # type: ignore
        c = 3
        d = 4 # type: ignore@tag
        T)type_commentsr   r1  r   r   r   	   z@tag)r   rz   r   r  r.   r   r(   tagr  s     r   test_increment_lineno_on_module/ASTHelpers_Test.test_increment_lineno_on_module  s    ii   
 	SA&))!,33Q7))!,33Q7))!,00&9r!   c                     [         R                  " SSS9n[        [         R                  " UR                  5      5      nU R                  UR                  S5      R                  S5        U R                  U/ / S.5        g )Nfoo()rg   r  r  r   )r  r  )r   rz   r  iter_fieldsr   r.   popr   )r   r   ds      r   test_iter_fields ASTHelpers_Test.test_iter_fields  s\    yyv.+,v))51R89r!   c           	      .   [         R                  " SSS9nU R                  [        [	        [         R
                  " UR                  5      5      5      S5        [         R
                  " UR                  5      nU R                  [        U5      R                  S5        U R                  [        U5      R                  S5        U R                  [        U5      R                  S5        U R                  [         R                  " [        U5      5      S5        g )	Nzspam(23, 42, eggs='leek')rg   r  r   ra     r9   z1keyword(arg='eggs', value=Constant(value='leek')))r   rz   r.   r   r,   rb  r   r  r   r3   ro  )r   r   iterators      r   test_iter_child_nodes%ASTHelpers_Test.test_iter_child_nodes  s    yy46BT#"6"6tyy"ABCQG''		2h**F3h--r2h--r2HHT(^$?	
r!   c                 R   [         R                  " S5      nU R                  [         R                  " U5      S5        [         R                  " S5      nU R                  [         R                  " UR                  S   5      S5        [         R                  " S5      nU R                  [         R                  " UR                  S   5      S5        [         R                  " S5      nU R                  [         R                  " UR                  S   5      S5        [         R                  " S5      nU R                  [         R                  " UR                  S   SS	9S
5        [         R                  " S5      nU R                  [        [         R                  UR                  S   5        g )Nz"""line one
  line two"""zline one
line twoz&class foo:
  """line one
  line two"""r   z&def foo():
  """line one
  line two"""z#async def foo():
  """spam
  ham"""zspam
hamF)cleanz
spam
  hamrB   )r   rz   r.   get_docstringr   r=   r@   r  s     r   test_get_docstring"ASTHelpers_Test.test_get_docstring  s&   yy56**402FGyyCD**499Q<8:NOyyCD**499Q<8:NOyy@A**499Q<8+Fyy@A**499Q<uE}Uyy~)S%6%6		!Er!   c                    U R                  [        R                  " [        R                  " S5      5      5        [        R                  " S5      nU R                  [        R                  " U5      5        [        R                  " S5      nU R                  [        R                  " U5      5        [        R                  " S5      nU R                  [        R                  " UR                  S   5      5        [        R                  " S5      nU R                  [        R                  " UR                  S   5      5        [        R                  " S5      nU R                  [        R                  " UR                  S   5      5        [        R                  " S5      nU R                  [        R                  " UR                  S   5      5        [        R                  " S5      nU R                  [        R                  " UR                  S   5      5        [        R                  " S	5      nU R                  [        R                  " UR                  S   5      5        [        R                  " S
5      nU R                  [        R                  " UR                  S   5      5        [        R                  " S5      nU R                  [        R                  " UR                  S   5      5        g )Nr   zx = "not docstring"zdef foo():
  passzclass foo:
  passr   z class foo:
  x = "not docstring"z class foo:
  def bar(self): passz def foo():
  x = "not docstring"zasync def foo():
  passz&async def foo():
  x = "not docstring"zasync def foo():
  42)ra   r   r  rz   r   r  s     r   test_get_docstring_none'ASTHelpers_Test.test_get_docstring_none  s   #++CIIbM:;yy./#++D12yy-.#++D12yy-.#++DIIaL9:yy<=#++DIIaL9:yy<=#++DIIaL9:yy-.#++DIIaL9:yy<=#++DIIaL9:yy34#++DIIaL9:yyBC#++DIIaL9:yy12#++DIIaL9:r!   c                 4   [         R                  " S5      nU R                  UR                  S   R                  S5        U R                  UR                  S   R
                  S5        U R                  UR                  S   R                  S   R                  S5        U R                  UR                  S   R                  S   R
                  S5        U R                  UR                  S   R                  S   R                  S   R                  S5        U R                  UR                  S   R                  S   R                  S   R
                  S5        U R                  UR                  S   R                  S   R                  S5        U R                  UR                  S   R                  S   R
                  S5        U R                  UR                  S   R                  S5        U R                  UR                  S   R
                  S	5        g )
Nz"""line one
line two"""

def foo():
  """line one
  line two"""

  def bar():
    """line one
    line two"""
  """line one
  line two"""
"""line one
line two"""

r   r   r;   r   r   r  r     )r   rz   r.   r   r)   r(   r  s     r   :test_multi_line_docstring_col_offset_and_lineno_issue16806JASTHelpers_Test.test_multi_line_docstring_col_offset_and_lineno_issue16806  s   yy+
 	100!41,,a01**1-88!<1**1-44a81**1-2215@@!D1**1-2215<<a@1**1-88!<1**1-44b9100!41,,b1r!   c                     [         R                  " S5      nUR                  S   R                  S   nU R	                  UR
                  S5        U R	                  UR                  S5        g )Nz if a:
    pass
elif b:
    pass
r   r   r   rz   r   orelser.   r(   r)   r   r   	elif_stmts      r   test_elif_stmt_start_position-ASTHelpers_Test.test_elif_stmt_start_position!  sU    yy?@IIaL''*	))1---q1r!   c                     [         R                  " S5      nUR                  S   R                  S   nU R	                  UR
                  S5        U R	                  UR                  S5        g )Nz/if a:
    pass
elif b:
    pass
else:
    pass
r   r   r  r  s      r   'test_elif_stmt_start_position_with_else7ASTHelpers_Test.test_elif_stmt_start_position_with_else'  sU    yyPQIIaL''*	))1---q1r!   c                     [         R                  " S5      nUR                  S   R                  R                  S   nU R                  UR                  S5        U R                  UR                  S5        g )Nz
f(*[0, 1])r   r   r  )r   rz   r   r3   r  r.   r   r   )r   r   starred_exprs      r   *test_starred_expr_end_position_within_call:ASTHelpers_Test.test_starred_expr_end_position_within_call-  sZ    yy&yy|))..q100!444a8r!   c                 6   U R                  [        R                  " S5      / SQ5        U R                  [        R                  " S5      SS05        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      1 S	k5        U R                  [        R                  " S
5      S5        U R                  [        R                  " S5      [        5       5        U R	                  [
        [        R                  S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        [        R                  " S5      5      S5        U R	                  [
        [        R                  S5        U R	                  [
        [        R                  S5        U R	                  [
        [        R                  S5        g )Nz	[1, 2, 3]r   r;   r   z{"foo": 42}r   r9   z(True, False, None)rL  z	{1, 2, 3}>   r   r;   r   zb"hi"s   hizset()r  6   z+6z-6iz3.25g      
@z+3.25z-3.25g      
z-0.0z++6z+Truez2+3)r.   r   rt  setr=   r   reprr   s    r   test_literal_eval!ASTHelpers_Test.test_literal_eval3  s   ))+6	B))-85"+F))*?@BUV))+6	B))'2E:))'2CE:*c&6&6@))#.2))$/3))$/4))&148))'2D9))'2E:c..v67@*c&6&6>*c&6&6@*c&6&6>r!   c                    [         R                  " S5         [        R                  " S5        U R	                  [
        5       n[        R                  " S5        S S S 5        U R                  S[        WR                  5      5        U R                  S[        UR                  5      5        S S S 5        g ! , (       d  f       Na= f! , (       d  f       g = f)Ni    3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333  33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333zExceeds the limit z Consider hexadecimal )	r   adjust_int_max_str_digitsr   rt  r=   r  r  r  r  )r   err_ctxs     r   test_literal_eval_str_int_limit/ASTHelpers_Test.test_literal_eval_str_int_limitF  s    ..t4Z("";/7  , 0MM.G4E4E0FGMM2C8I8I4JK 54// 54s$   ,CB5AC5
C	?C
Cc                 R   U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S	5      S
5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S
5        U R                  [        [        R                  S5        U R                  [        [        R                  S5        U R                  [        [        R                  S5        U R                  [        [        R                  S5        U R                  [        [        R                  S5        g )N6jy              @z-6jy             z6.75jy              @z-6.75jy             z3+6jy      @      @z-3+6jy            @z3-6jy      @      z-3-6jy            z
3.25+6.75jy      
@      @z-3.25+6.75jy      
      @z
3.25-6.75jy      
@      z-3.25-6.75jy      
      z(3+6j)z-6j+3z-6j+3jz3+-6jz3+(0+6j)z-(3+6j))r.   r   rt  r=   r   r   s    r   test_literal_eval_complex)ASTHelpers_Test.test_literal_eval_complexN  s   ))$/4))%0#6))'2E:))(3V<))&16:))'2G<))&16:))'2G<)),7F))-8-H)),7F))-8-H))(3V<*c&6&6@*c&6&6A*c&6&6@*c&6&6
C*c&6&6	Br!   c                    [         R                  " [         R                  " S5      [         R                  " S5      /[         R                  " S5      /S9nU R                  [        [         R
                  U5        [         R                  " [         R                  " S5      /[         R                  " S5      [         R                  " S5      /S9nU R                  [        [         R
                  U5        g )Nr   r;   r   )keysvalues)r   Dictr   r=   r   rt  )r   	malformeds     r   &test_literal_eval_malformed_dict_nodes6ASTHelpers_Test.test_literal_eval_malformed_dict_nodesc  s    HH,,q/3<<?3S\\!_<M
	 	*c&6&6	BHH,,q/"CLLOS\\!_+M
	 	*c&6&6	Br!   c                 2   U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        [        R                  S5        g )Nz    -1r   z		-1z 	 -1z
 -1)r.   r   rt  r=   IndentationErrorr   s    r   test_literal_eval_trailing_ws-ASTHelpers_Test.test_literal_eval_trailing_wsm  sl    ))(3R8))(3R8))(3R8*C,<,<gFr!   c           	      (   SnU R                  [        U5         [        R                  " S5        S S S 5        [        R                  " [        R
                  " 5       [        R                  " [        R
                  " 5       [        R                  " S5      5      5      nU R                  [        USS 5      5        SnU R                  [        U5         [        R                  " U5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nz#malformed node or string on line 3:z{'a': 1,
'b':2,
'c':++3,
'd':4}r  r(   zmalformed node or string:)	rN   r   r   rt  UnaryOpUAddr   ra   r+   )r   rO   r   s      r   "test_literal_eval_malformed_lineno2ASTHelpers_Test.test_literal_eval_malformed_linenos  s    4##J4AB 5 {{388:s{{388:s||A'OP'$$78*##J4T" 54 54 54s   C2D2
D 
Dc                     U R                  [        S5         [        R                  " S5        S S S 5        g ! , (       d  f       g = f)Nzunexpected indentz4
                \
                (\
            \ )rN   r  r   rt  r   s    r   test_literal_eval_syntax_errors/ASTHelpers_Test.test_literal_eval_syntax_errors~  s3    ##K1DE   FEEs	   7
Ac                 L   [         R                  " S[         R                  " SS9/S S S S9/n[         R                  " U/ 5      nU R	                  [
        5       n[        USS5        S S S 5        U R                  S[        WR                  5      5        g ! , (       d  f       N4= f)Ntimesleepr   r   r   levelr(   r)   r  re   zinvalid integer value: None)
r   r   r   r   r=   r   rp   r  r  r  )r   r   r   r  s       r   test_bad_integer ASTHelpers_Test.test_bad_integer  s     NNyyg./
 jjr"z*bC( +3S5FG +*s   B
B#c           	          [         R                  " S[         R                  " SSSS9/S SSS9/n[         R                  " U/ 5      n[	        USS5      n0 n[        X45        U R                  SU5        g )Nr  r  r   r   r  r  re   )r   r   r   r   rp   re   r  )r   r   r   r  nss        r   test_level_as_none"ASTHelpers_Test.test_level_as_none  sn    NNyygaAFG
 jjr"sFF+Tgr"r!   c                    [         R                  " [         R                  " 5       SS[         R                  " S5      S9nXl        U R                  [        5         [        R                  " 5          [        [         R                  " U5      SS5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = fNr   r   )r  r(   r)   operandr   rg   r   r  Notr   r  r=   r   r   r!  rp   r  rw  s     r   test_recursion_direct%ASTHelpers_Test.test_recursion_direct  sv    KK3779Q1cllSToV	~.++-q)8V< . /.-- /.s$   B40"B#B4#
B1	-B44
Cc                    [         R                  " [         R                  " 5       SS[         R                  " S5      S9n[         R                  " [         R                  " 5       SS[         R                  " S5      S9nX!l        Xl        U R                  [        5         [        R                  " 5          [        [         R                  " U5      SS5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = fr  r  )r   rX  fs      r   test_recursion_indirect'ASTHelpers_Test.test_recursion_indirect  s    KK3779Q1cllSToVKK3779Q1cllSToV		~.++-q)8V< . /.-- /.s$   C84"C'C8'
C5	1C88
D)rQ  )#rW   r   rX   rY   rQ  rp  rx  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  rZ   r8   r!   r   rm  rm  x  s    G3
:
.>
@A
FX
t,(
*@4::

F&;62&229?&LC*CG	#H # ==r!   rm  c                    z
   \ rS rSrSI\S.S jjrSJ\S.S jjrSJS jrS rS r	S	 r
S
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S  r!S! r"S" r#S# r$S$ r%S% r&S& r'S' r(S( r)S) r*S* r+S+ r,S, r-S- r.S. r/S/ r0S0 r1S1 r2S2 r3\4Rj                  " S35      S4 5       r6\7Rp                  " S55      r9\7Rt                  " \95      r;\7Rp                  " S65      r<\7Rt                  " \<5      r=\7Rp                  " S75      r>\7R~                  " S75      r@\7R                  " S8\7R                  " 5       5      rC\7Rt                  " \7R                  " \7R                  " \7R                  " S6\7R                  " 5       5      S9\7R                  " 5       5      S:\7R                  " 5       5      5      \7Rt                  " \7R                  " \7R                  " \7R                  " S6\7R                  " 5       5      S9\7R                  " 5       5      S:\7R                  " 5       5      5      \7Rt                  " \7Rp                  " S;5      5      \7Rt                  " \7Rp                  " S75      5      \7Rt                  " \7Rp                  " S<5      5      \7R~                  " S=5      \7R                  " \7R~                  " S=5      /5      \7R                  " \7R                  " \7R~                  " S=5      /5      /5      \7R                  " \9\>/\=/5      \7R                  " \>\9/\=\;/S>S?9\7R                  " \>\7R                  " \7R                  " S@\7R                  " 5       5      \7R                  " 5       5      /\=\;/SAS?9\7R                  " \7R                  " \7R                  " \<S9\7R                  " 5       5      S:\7R                  " 5       5      / / / SB9\7R                  " \C/ S>/\;/SB9\7R                  " \C/ / \;/SB9\7R                  " \C\7R~                  " S=5      // / SB9\7R                  " \C\7R                  " 5       // / SB9\7R                  " \C/ / \7R                  " 5       /SB9\7R                  " \>/ S>/\;/SB9\7R                  " \7R                  " S>5      /5      \7R                  " SCSD9\7R                  " / 5      \7R                  " \;/5      \7R                  " \;\=\7R~                  " SE5      /5      \7R                  " SFSD9\7R                  " S6SD9\7R                  " \7R                  " SF5      /5      \7R                  " / / SFS?9/rMSG rNSHrOg)KASTValidatorTestsi  Nr  c                (   S=Ul         Ul        [        R                  " U5        Uc  [	        USU5        g U R                  U5       n[	        USU5        S S S 5        U R                  U[        WR                  5      5        g ! , (       d  f       N4= f)Nr   r   )	r(   r)   r   r  rp   r=   r  r  r  )r   r   rO   r  r  r  s         r   r   ASTValidatorTests.mod  sp    &''
S^!!#&;C4(""3'2Xt, (MM#s2<<01 ('s   B
Bc                |    [         R                  " [         R                  " U5      // 5      nU R                  XBUS9  g )Nr&  )r   r   r   r   )r   r   rO   r  r   s        r   r%   ASTValidatorTests.expr  s-    jj#((4.)2.s#r!   c                 V    [         R                  " U// 5      nU R                  X25        g rG   )r   r   r   )r   r&   rO   r   s       r   r&   ASTValidatorTests.stmt  s     jj$$r!   c           	      r   [         R                  " [         R                  " [         R                  " S[         R                  " 5       5      5      /5      nU R                  USS5        [         R                  " [         R                  " S[         R                  " 5       5      5      nU R                  USS5        g )NrB   must have Load contextrf   rg   )r   Interactiver   r   Storer   r  )r   r  s     r   r~  ASTValidatorTests.test_module  sn    OOSXXchhsCIIK&@ABC,h7NN388C56,f5r!   c                   ^        SU4S jjn[         R                  " S[         R                  " S[         R                  " 5       5      5      /nU" U" US9S5        U" U" US9S5        U" U" US9S5        U" U" [         R                  " S5      /S9S	5        U" U" [         R                  " S
5      /S9S5        [         R                  " S[         R                  " S[         R
                  " 5       5      5      /nU" U" U[         R                  " S[         R                  " 5       5      /S9S5        [         R                  " S[         R                  " S[         R
                  " 5       5      5      [         R                  " S[         R                  " S[         R
                  " 5       5      5      /nU" U" US [         R                  " S[         R                  " 5       5      /S9S5        g )Nc           	      x   > U c  / n Uc  / nUc  / nUc  / nUc  / n[         R                  " XX#XdU5      n T" U 5      $ rG   )r   r  )r  r  r?   r  r  r  r  facs          r   r  5ASTValidatorTests._check_arguments.<locals>.arguments  s^     |" !
" ==6{8D t9r!   rB   r  r.  r  )r  r   )r  z"more positional defaults than argsr   )r  z3length of kwonlyargs is not the same as kw_defaults)r  r  r]   rW  r   )r  r  )NNNNNNN)r   r  r   r0  r   r  )r   r4  checkr  r  s    `   r   _check_arguments"ASTValidatorTests._check_arguments  st   	0 SXXc399;789iT"$<=iD)+CDi4(*BCQ013W	
 	3<<?"34A	
 SXXc388:6784388C+E*FG$	

 GGC#sxxz23GGC#sxxz23
 	D#((3		:T3UV$	
r!   c                    [         R                  " / / S / / S / 5      n[         R                  " SU/ / S S / 5      nU R                  US5        [         R                  " SU[         R                  " 5       /[         R
                  " S[         R                  " 5       5      /S S / 5      nU R                  US5        [         R                  " SU[         R                  " 5       // [         R
                  " S[         R                  " 5       5      S / 5      nU R                  US5        [         R                  " S[         R                  " 5       [         R                  " 5       /5      nU R                  U5        S nU R                  X0R                  5        g )NrB   zempty body on FunctionDefr.  c           	      b    [         R                  " SU [         R                  " 5       // S S / 5      $ NrB   )r   FunctionDefPassr  s    r   r4  +ASTValidatorTests.test_funcdef.<locals>.fac  s%    ??3sxxzlBdBOOr!   )r   r  r<  r&   r=  r   r0  r7  )r   r]   r!  r4  s       r   test_funcdefASTValidatorTests.test_funcdef  s   MM"b$Bb9OOCBD$;		!01OOSXXZL388C#=">dB
 			!-.OOSXXZL"chhsCIIK&@$
 			!-.OOC388:,?		!	P 	c99-r!   c                     S nSn[         R                  " [        R                  " U5      5      nUR                  S   nU R                  U[         R                  5        U R                  U" U5      5        g )Nc                    U [         R                  S`=b  u  S:X  a  [         R                  S` =b  u   a   S:H  a  u  [         R                  S`=b  u  S:X  a   a   S:H  a  u  [         R                  S` =bq  u    am   S:H  ag  u  [         R
                  S`=bQ  u  S:X  aJ  [         R                  S` =b6  u   [         R
                  S`=b!  u  S:X  a  [         R                  S` =b  u   g         g	)
Nr8   r   r  r   r   r  pacaranaTF)r   r<  r  r  r=  r   r  )r   s    r   matcher@ASTValidatorTests.test_funcdef_pattern_matching.<locals>.matcher  sx    __ MM8'7'7 LSXXZ66SXX5j#((*HH4Z  r!   zZ
            @capybara
            def foo(bar) -> pacarana:
                pass
        r   )r   rz   ra  r   r   r   r<  r   )r   rD  r  r:  funcdefs        r   test_funcdef_pattern_matching/ASTValidatorTests.test_funcdef_pattern_matching  sY    	!
 8??401++a.gs7()r!   c                     S
S jnU R                  U" [        R                  " S[        R                  " 5       5      /S9S5        U R                  U" [        R                  " S[        R                  " S[        R                  " 5       5      5      /S9S5        U R                  U" / S9S5        U R                  U" S /S9S5        U R                  U" [        R                  " S[        R                  " 5       5      /S	9S5        g )Nc                     U c  / n Uc  / nUc  [         R                  " 5       /nUc  / nUc  / n[         R                  " SXX#U5      $ )Nmyclass)r   r=  r  )basesr  r   r#   type_paramss        r   r  ,ASTValidatorTests.test_classdef.<locals>.cls/  s[     }|
|%!#" <<5D+ r!   rB   )rL  r.  )r  r  zempty body on ClassDefNone disallowed)r#   )NNNNN)r&   r   r   r0  rL  )r   r  s     r   test_classdefASTValidatorTests.test_classdef.  s    SW	" 			#SXXc399;789;ST		#++c388C+EFGH$	
 			#2, 89		#D6"$56		ciik :;<>V	
r!   c           	      <   U R                  [        R                  " / 5      S5        U R                  [        R                  " S /5      S5        U R                  [        R                  " [        R                  " S[        R                  " 5       5      /5      S5        g )Nzempty targets on DeleterO  rB   zmust have Del context)r&   r   Deleter   r  r   s    r   test_deleteASTValidatorTests.test_deleteK  s_    		#**R.";<		#**dV$&78		#**chhsCHHJ789;RSr!   c           
         U R                  [        R                  " / [        R                  " S5      5      S5        U R                  [        R                  " S /[        R                  " S5      5      S5        U R                  [        R                  " [        R                  " S[        R
                  " 5       5      /[        R                  " S5      5      S5        U R                  [        R                  " [        R                  " S[        R                  " 5       5      /[        R                  " S[        R                  " 5       5      5      S5        g )Nr   zempty targets on AssignrO  rB   must have Store contextr   r.  )r&   r   Assignr   r   r  r0  r   s    r   test_assignASTValidatorTests.test_assignP  s    		#**Ra13LM		#**dVS\\!_57HI		JJchhj12CLLOD%	
 			JJciik23SXXc399;5OP$	
r!   c           	      8   [         R                  " [         R                  " S[         R                  " 5       5      [         R                  " 5       [         R                  " S[         R                  " 5       5      5      nU R                  US5        [         R                  " [         R                  " S[         R                  " 5       5      [         R                  " 5       [         R                  " S[         R                  " 5       5      5      nU R                  US5        g )NrB   r   rW  r.  )r   	AugAssignr   r  r   r&   r0  )r   augs     r   test_augassign ASTValidatorTests.test_augassign\  s    mmHHS#((*%swwy#((3
2K
 			#01mmHHS#))+&	388C3M
 			#/0r!   c           
         [         R                  " S[         R                  " 5       5      n[         R                  " S[         R                  " 5       5      n[         R                  " 5       nU R                  [         R                  " X/ / 5      S5        U R                  [         R                  " [         R                  " S[         R                  " 5       5      X#// 5      S5        U R                  [         R                  " U[         R                  " S[         R                  " 5       5      U// 5      S5        [         R                  " [         R                  " S[         R                  " 5       5      5      nU R                  [         R                  " XU// 5      S5        U R                  [         R                  " XU/U/5      S5        g )NrB   r   zempty body on ForrW  r.  )r   r   r0  r  r=  r&   r   r   )r   rB   r   prX  s        r   test_forASTValidatorTests.test_forf  s   HHS#))+&HHS#((*%HHJ		#''!B')<=		GGCHHS#((*-q#r:<U	
 			GGAsxxSYY[1A3;=U	
 HHSXXc399;/0		#''!R(*BC		#''!aS)+CDr!   c                 ^   U R                  [        R                  " [        R                  " S5      / / 5      S5        U R                  [        R                  " [        R                  " S[        R
                  " 5       5      [        R                  " 5       // 5      S5        U R                  [        R                  " [        R                  " S5      [        R                  " 5       /[        R                  " [        R                  " S[        R
                  " 5       5      5      /5      S5        g )Nr   zempty body on WhilerB   r.  )r&   r   Whiler   r   r0  r=  r   r   s    r   
test_whileASTValidatorTests.test_whileu  s    		#))CLLOR46KL		IIchhsCIIK0388:,C$	
 			IIQ#((*#syy{9S0T/U %		
r!   c                 \   U R                  [        R                  " [        R                  " S5      / / 5      S5        [        R                  " [        R                  " S[        R
                  " 5       5      [        R                  " 5       // 5      nU R                  US5        [        R                  " [        R                  " S5      [        R                  " [        R                  " S[        R
                  " 5       5      5      // 5      nU R                  US5        [        R                  " [        R                  " S5      [        R                  " 5       /[        R                  " [        R                  " S[        R
                  " 5       5      5      /5      nU R                  US5        g )Nr   zempty body on IfrB   r.  )r&   r   Ifr   r   r0  r=  r   )r   rs   s     r   test_ifASTValidatorTests.test_if  s    		#&&a"b13EFFF388C-
|R@		!-.FF3<<?SXXchhsCIIK.H%I$JBO		!-.FFLLOchhj\CHHSXXc399;5O,P+Q
 			!-.r!   c                    [         R                  " 5       nU R                  [         R                  " / U/5      S5        [         R                  " [         R
                  " S5      S 5      nU R                  [         R                  " U// 5      S5        [         R                  " [         R                  " S[         R                  " 5       5      S 5      nU R                  [         R                  " U/U/5      S5        [         R                  " [         R
                  " S5      [         R                  " S[         R                  " 5       5      5      nU R                  [         R                  " U/U/5      S5        g )Nzempty items on Withr   zempty body on WithrB   r.  rW  )	r   r=  r&   Withr  r   r   r0  r  )r   ra  rs   s      r   	test_withASTValidatorTests.test_with  s    HHJ		#((2s#%:;LLa$/		#((A3#%9:LL#syy{3T:		#((A3$&>?LLa#((3
*CD		#((A3$&?@r!   c                    [         R                  " S [         R                  " S5      5      nU R                  US5        [         R                  " [         R                  " S[         R
                  " 5       5      S 5      nU R                  US5        [         R                  " [         R                  " S5      [         R                  " S[         R
                  " 5       5      5      nU R                  US5        g )Nr   z!Raise with cause but no exceptionrB   r.  r   )r   r  r   r&   r   r0  )r   rs     r   
test_raiseASTValidatorTests.test_raise  s    IIdCLLO,		!89IIchhsCIIK0$7		!-.IIcll1osxxSYY['AB		!-.r!   c                 D   [         R                  " 5       n[         R                  " / / / U/5      nU R                  US5        [         R                  " [         R                  " [         R
                  " S[         R                  " 5       5      5      // / U/5      nU R                  US5        [         R                  " U// / / 5      nU R                  US5        [         R                  " U// U/U/5      nU R                  US5        [         R                  " U/[         R                  " S S/ 5      // / 5      nU R                  US5        [         R                  " [         R
                  " S[         R                  " 5       5      SU/5      /nU R                  [         R                  " U/U/ / 5      S5        [         R                  " S SU/5      /n[         R                  " U/U[         R                  " [         R
                  " S[         R                  " 5       5      5      /U/5      nU R                  US5        [         R                  " U/X1/[         R                  " [         R
                  " S[         R                  " 5       5      5      /5      nU R                  US5        g )Nzempty body on TryrB   r.  z-Try has neither except handlers nor finalbodyz%Try has orelse but no except handlersempty body on ExceptHandlerr   )r   r=  Tryr&   r   r   r0  ExceptHandlerr   ra  trX  s       r   test_tryASTValidatorTests.test_try  s   HHJGGBB$		!()GGSXXchhsCIIK89:BQCH		!-.GGQCR$		!DEGGQCaS1#&		!<=GGQC#++D#r:;RD		!23sxxSYY[93DE		#''1#q"b)+CDtS1#./GGQCSXXchhsCIIK&@ABQCH		!-.GGQCC#((388C+E"F!GH		!-.r!   c                 D   [         R                  " 5       n[         R                  " / / / U/5      nU R                  US5        [         R                  " [         R                  " [         R
                  " S[         R                  " 5       5      5      // / U/5      nU R                  US5        [         R                  " U// / / 5      nU R                  US5        [         R                  " U// U/U/5      nU R                  US5        [         R                  " U/[         R                  " S S/ 5      // / 5      nU R                  US5        [         R                  " [         R
                  " S[         R                  " 5       5      SU/5      /nU R                  [         R                  " U/U/ / 5      S5        [         R                  " S SU/5      /n[         R                  " U/U[         R                  " [         R
                  " S[         R                  " 5       5      5      /U/5      nU R                  US5        [         R                  " U/X1/[         R                  " [         R
                  " S[         R                  " 5       5      5      /5      nU R                  US5        g )Nzempty body on TryStarrB   r.  z1TryStar has neither except handlers nor finalbodyz)TryStar has orelse but no except handlersru  r   )r   r=  TryStarr&   r   r   r0  rw  rx  s       r   test_try_starASTValidatorTests.test_try_star  s   HHJKKBQC(		!,-KK#((3		"<=>BL		!-.KKRR(		!HIKKR!qc*		!@AKKc//c2>?RH		!23sxxSYY[93DE		#++qc1b"-/GHtS1#./KKQ#((3		*D!E FL		!-.KKQchhsxxSYY[/I&J%KL		!-.r!   c           	         U R                  [        R                  " [        R                  " S[        R                  " 5       5      S 5      S5        [        R                  " [        R                  " S[        R
                  " 5       5      [        R                  " S[        R                  " 5       5      5      nU R                  US5        g )NrB   r.  r   )r&   r   Assertr   r0  r  )r   assrts     r   test_assertASTValidatorTests.test_assert  ss    		JJsxxSYY[148:R	
 

388C4chhsCIIK6PQ		%12r!   c                 P    U R                  [        R                  " / 5      S5        g )Nzempty names on Import)r&   r   r   r   s    r   test_importASTValidatorTests.test_import      		#**R."9:r!   c                     [         R                  " S [         R                  " SS 5      /S5      nU R                  US5        U R                  [         R                  " S / S5      S5        g )NrB   izNegative ImportFrom levelr   zempty names on ImportFrom)r   r   r   r&   )r   imps     r   test_importfrom!ASTValidatorTests.test_importfrom  sM    nnTCIIc4$8#93?		#23		#..r1-/JKr!   c                 P    U R                  [        R                  " / 5      S5        g )Nzempty names on Global)r&   r   Globalr   s    r   test_globalASTValidatorTests.test_global  r  r!   c                 P    U R                  [        R                  " / 5      S5        g )Nzempty names on Nonlocal)r&   r   Nonlocalr   s    r   test_nonlocalASTValidatorTests.test_nonlocal  s    		#,,r"$=>r!   c                     [         R                  " [         R                  " S[         R                  " 5       5      5      nU R	                  US5        g NrB   r.  )r   r   r   r0  r&   rw  s     r   	test_exprASTValidatorTests.test_expr  s0    HHSXXc399;/0		!-.r!   c           	         [         R                  " [         R                  " 5       / 5      nU R                  US5        [         R                  " [         R                  " 5       [         R                  " S5      /5      nU R                  US5        [         R                  " [         R                  " 5       [         R                  " S5      S /5      nU R                  US5        [         R                  " [         R                  " 5       [         R                  " S5      [         R
                  " S[         R                  " 5       5      /5      nU R                  US5        g )Nzless than 2 valuesr   r   rO  rB   r.  )r   BoolOpAndr%   r   r   r0  )r   rW  s     r   test_boolopASTValidatorTests.test_boolop  s    JJswwy"%		!)*JJswwy3<<?"34		!)*JJswwy3<<?D"9:		!&'JJswwy3<<?CHHS#))+4N"OP		!-.r!   c                     [         R                  " [         R                  " 5       [         R                  " S[         R                  " 5       5      5      nU R                  US5        g r  )r   r  r  r   r0  r%   )r   us     r   test_unaryopASTValidatorTests.test_unaryop  s8    KK	388C#=>		!-.r!   c           
         [         R                  " / / S / / S / 5      nU R                  [         R                  " U[         R                  " S[         R
                  " 5       5      5      S5        S nU R                  X R                  5        g )NrB   r.  c                     [         R                  " U [         R                  " S[         R                  " 5       5      5      $ r;  )r   Lambdar   r  r  s    r   r4  *ASTValidatorTests.test_lambda.<locals>.fac  s$    ::dCHHS#((*$=>>r!   )r   r  r%   r  r   r0  r7  )r   r]   r4  s      r   test_lambdaASTValidatorTests.test_lambda  s`    MM"b$Bb9		#**Qciik :;=UV	? 	c99-r!   c                    [         R                  " S[         R                  " 5       5      n[         R                  " S[         R                  " 5       5      nX!U4XU4XU44 H&  nU R	                  [         R
                  " U6 S5        M(     g NrB   r   r.  )r   r   r  r0  r%   IfExp)r   lr>  r  s       r   
test_ifexpASTValidatorTests.test_ifexp  sc    HHS#((*%HHS#))+&1Iay1)3DIIcii&(@A 4r!   c                 N   [         R                  " / [         R                  " S[         R                  " 5       5      /5      nU R	                  US5        [         R                  " [         R                  " S[         R                  " 5       5      /S /5      nU R	                  US5        g )NrB   zsame number of keys as valuesrO  )r   r  r   r  r%   )r   r  s     r   	test_dictASTValidatorTests.test_dict  sj    HHR#((3
345		!45HHchhsCHHJ/04&9		!&'r!   c                     U R                  [        R                  " S /5      S5        [        R                  " [        R                  " S[        R                  " 5       5      /5      nU R                  US5        g NrO  rB   r.  )r%   r   Setr   r0  r   r>  s     r   test_setASTValidatorTests.test_set  sL    		#''4&/#45GGSXXc399;/01		!-.r!   c           	         U R                  U" / 5      S5        [        R                  " [        R                  " S[        R                  " 5       5      [        R                  " S[        R                  " 5       5      / S5      nU R                  U" U/5      S5        [        R                  " [        R                  " S[        R
                  " 5       5      [        R                  " S[        R
                  " 5       5      / S5      nU R                  U" U/5      S5        [        R                  " S[        R
                  " 5       5      n[        R                  " S[        R                  " 5       5      n[        R                  " X4S /S5      nU R                  U" U/5      S5        [        R                  " X4[        R                  " S[        R
                  " 5       5      /S5      nU R                  U" U/5      S5        g )Nz comprehension with no generatorsrB   r   rW  r.  r   rO  )r%   r   r   r   r  r0  )r   r4  grB   r   s        r   _check_comprehension&ASTValidatorTests._check_comprehension  sM   		#b'=>HHS#((*%sxxSXXZ'@"a
 			#qc(56HHS#))+&ciik(BB
 			#qc(45HHS#))+&HHS#((*%aTFA.		#qc(-.aSXXc399;%?$@!D		#qc(45r!   c           	        ^ [         R                  " [         R                  " S[         R                  " 5       5      [         R                  " S[         R                  " 5       5      / S5      nU R                  T" [         R                  " S[         R                  " 5       5      U/5      S5        U4S jnU R                  U5        g )NrB   r   r.  c                 f   > T" [         R                  " S[         R                  " 5       5      U 5      $ r;  )r   r   r0  )gensr4  s    r   wrap,ASTValidatorTests._simple_comp.<locals>.wrap  s!    sxxSYY[1488r!   )r   r   r   r0  r  r%   r  )r   r4  r  r  s    `  r   _simple_compASTValidatorTests._simple_comp  s~    HHS#))+&chhj(A2q
 			#chhsCIIK01#68PQ	9 	!!$'r!   c                 B    U R                  [        R                  5        g rG   )r  r   ListCompr   s    r   test_listcompASTValidatorTests.test_listcomp$  s    #,,'r!   c                 B    U R                  [        R                  5        g rG   )r  r   SetCompr   s    r   test_setcompASTValidatorTests.test_setcomp'  s    #++&r!   c                 B    U R                  [        R                  5        g rG   )r  r   GeneratorExpr   s    r   test_generatorexp#ASTValidatorTests.test_generatorexp*  s    #**+r!   c                    [         R                  " [         R                  " S[         R                  " 5       5      [         R                  " S[         R                  " 5       5      / S5      n[         R
                  " [         R                  " S[         R                  " 5       5      [         R                  " S[         R                  " 5       5      U/5      nU R                  US5        [         R
                  " [         R                  " S[         R                  " 5       5      [         R                  " S[         R                  " 5       5      U/5      nU R                  US5        S nU R                  U5        g )Nr   ra  r   rB   r.  c                     [         R                  " S[         R                  " 5       5      n[         R                  " S[         R                  " 5       5      n[         R                  " XU 5      $ )NrB   r   )r   r   r  DictComp)compskvs      r   factory0ASTValidatorTests.test_dictcomp.<locals>.factory6  s?    chhj)Achhj)A<<e,,r!   )r   r   r   r0  r  r  r%   r  )r   r  cr  s       r   test_dictcompASTValidatorTests.test_dictcomp-  s    HHS#))+&chhj(A2q
 LL#syy{3SXXc388:5NQRPST		!-.LL#sxxz2CHHS#))+4NQRPST		!-.	-
 	!!'*r!   c           	      <   U R                  [        R                  " [        R                  " S[        R                  " 5       5      5      S5        U R                  [        R
                  " [        R                  " S[        R                  " 5       5      5      S5        g )NrB   zmust have Load)r%   r   Yieldr   r0  	YieldFromr   s    r   
test_yieldASTValidatorTests.test_yield=  sT    		#))CHHS#))+679IJ		#--ciik :;=MNr!   c                    [         R                  " S[         R                  " 5       5      n[         R                  " U[         R                  " 5       // 5      nU R                  US5        [         R                  " U[         R                  " 5       /[         R                  " S5      [         R                  " S5      /5      nU R                  US5        [         R                  " [         R                  " S5      [         R                  " 5       /U/5      nU R                  U5        [         R                  " U[         R                  " 5       /[         R                  " S5      /5      nU R                  U5        g )NrB   zno comparatorsr   r   z,different number of comparators and operandsblah)r   r   r  CompareInr%   r   )r   r  comps      r   test_compareASTValidatorTests.test_compareA  s    xxSXXZ({{4#&&(R0		$(){{4#&&(cll1os||A-OP		$FG{{3<</#&&(dVD		${{4#&&(cll6.B-CD		$r!   c                    [         R                  " S[         R                  " 5       5      n[         R                  " S[         R                  " 5       5      /n[         R                  " S[         R                  " S[         R                  " 5       5      5      /n[         R                  " [         R                  " S[         R
                  " 5       5      X#5      nU R                  US5        [         R                  " US /U5      nU R                  US5        [         R                  " S[         R                  " S[         R
                  " 5       5      5      /n[         R                  " XU5      nU R                  US5        g )NrB   r   rA  r   r.  rO  )r   r   r  rL  r  r0  r%   )r   r  r  r  callbad_keywordss         r   	test_callASTValidatorTests.test_callL  s    xxSXXZ(chhj)*KKSXXc388:%>?@xxciik2DC		$01xxtfh/		$)*C#syy{)CDExxL1		$01r!   c                    [         R                  " SS9 n[         R                  " SS[        5        SSKJn  S S S 5        [         R                  " SS9 n[         R                  " SS[        5         " S S	[        5      n " S
 S[        5      n " S S[        5      nS H(  nU R                  [        R
                  " U5      5        M*     U" 5       U" 5       U" 5       4 H,  nU R                  [        R
                  " U5      S[        S9  M.     S S S 5        U R                  W Vs/ s H  n[        UR                  5      PM     sn/ SQ5        g ! , (       d  f       GN = f! , (       d  f       NY= fs  snf )NTr+  r   r   r   r\  r-  c                       \ rS rSrSrg)*ASTValidatorTests.test_num.<locals>.subinti`  r8   NrV   r8   r!   r   subintr  `  rp  r!   r  c                       \ rS rSrSrg),ASTValidatorTests.test_num.<locals>.subfloatic  r8   NrV   r8   r!   r   subfloatr  c  rp  r!   r  c                       \ rS rSrSrg).ASTValidatorTests.test_num.<locals>.subcomplexif  r8   NrV   r8   r!   r   
subcomplexr  f  rp  r!   r  )0hellozinvalid typer&  )r7  r7  r7  r7  r7  )r   r   r   r   r   r   r  floatcomplexr%   r@   r.   r  r?  )r   r@  r   r  r  r  objrA  s           r   test_numASTValidatorTests.test_numX  s   $$D1T##Hb2DE 2 $$D1T##Hb2DE 5 W  $		#''#,' $xZ\9		#''#,I	F : 2" 	%)*TS^T*		
+ 21 21$ +s   #EB<E#'E4
E #
E1c                     [         R                  " [         R                  " S[         R                  " 5       5      S[         R                  " 5       5      nU R                  US5        g r  )r   	Attributer   r0  r  r%   )r   r9  s     r   test_attribute ASTValidatorTests.test_attributey  s:    }}SXXc399;7chhjI		$01r!   c           	         [         R                  " [         R                  " S[         R                  " 5       5      [         R                  " S5      [         R
                  " 5       5      nU R                  US5        [         R                  " S[         R
                  " 5       5      n[         R                  " U[         R                  " S[         R                  " 5       5      [         R
                  " 5       5      nU R                  US5        [         R                  " S[         R                  " 5       5      nUS S 4S US 4S S U44 HP  n[         R                  " U6 nU R                  [         R                  " X%[         R
                  " 5       5      S5        MR     [         R                  " / [         R
                  " 5       5      nU R                  [         R                  " X%[         R
                  " 5       5      5        [         R                  " U/[         R
                  " 5       5      nU R                  [         R                  " X%[         R
                  " 5       5      S5        g )NrB   r   r.  r   )	r   	Subscriptr   r0  r   r  r%   SliceTuple)r   subrB   r>  r  sls         r   test_subscript ASTValidatorTests.test_subscript}  se   mmCHHS#))+6QT		#/0HHS#((*%mmAsxxSYY[9388:F		#/0HHS#))+&dOdAt_tT1oEDD!BIIcmmA388:68PQ F YYr388:&		#--sxxz23YYsCHHJ'		#--sxxz24LMr!   c           	      v   [         R                  " [         R                  " [         R                  " S[         R                  " 5       5      [         R
                  " 5       5      /[         R
                  " 5       5      n[         R                  " U/[         R                  " S5      5      nU R                  US5        g )NrB   r   rW  )	r   ListStarredr   r  r0  rX  r   r&   )r   r  assigns      r   test_starredASTValidatorTests.test_starred  sk    xx[[#sxxz2CIIK@A399;
 TFCLLO4		&34r!   c           	         U R                  U" S /[        R                  " 5       5      S5        U R                  U" [        R                  " S[        R                  " 5       5      /[        R                  " 5       5      S5        g r  )r%   r   r  r   r0  )r   r4  s     r   	_sequenceASTValidatorTests._sequence  sS    		#tfchhj)+<=		#syy{+,chhj9;S	
r!   c                 B    U R                  [        R                  5        g rG   )r  r   r  r   s    r   	test_listASTValidatorTests.test_list  s    sxx r!   c                 B    U R                  [        R                  5        g rG   )r  r   r  r   s    r   
test_tupleASTValidatorTests.test_tuple  s    syy!r!   c                    [         R                  " SS9 n[         R                  " SS[        5        SSKJn  S S S 5        [         R                  " SS9 n[         R                  " SS[        5        U R                  [        R
                  " S5      5        S S S 5        U R                  W Vs/ s H  n[        UR                  5      PM     snS	/5        g ! , (       d  f       N= f! , (       d  f       NW= fs  snf )
NTr+  r   r   r   )r   r-  r   r=  )
r   r   r   r   r   r   r%   r.   r  r?  )r   r@  r   rA  s       r   test_nameconstant#ASTValidatorTests.test_nameconstant  s    $$D1T##Hb2DE( 2 $$D1T##Hb2DEIIc&&q)* 2 	%)*TS^T*m	
 21 21
 +s   #CAC'-C8
C$'
C5cpuc                 `   [         R                  R                  [        R                  5      n[         R
                  " U5       Vs/ s H  o"R                  S5      (       d  M  UPM     nnUR                  SS/5        U H  nU R                  U5         [         R                  R                  X5      n[        USSS9 nUR                  5       nS S S 5        [        R                  " WU5      n[        XrS5        S S S 5        M     g s  snf ! , (       d  f       NC= f! , (       d  f       M  = f)Nz.pyztest/test_grammar.pyztest/test_unpack_ex.pyrq  utf-8encodingre   )ospathdirnamer   __file__listdirendswithextendro   joinopenreadrz   rp   )r   stdlibfnrN  r   fpr:  r   s           r   test_stdlib_validates'ASTValidatorTests.test_stdlib_validates  s    . jj0G0KK4F0G,.FGHFf%WW\\&1"cG4WWYF 5ii+( &%  H
 54 &%s0   D#D+D?D+D
DD
D-	r   rB   Tcarterr   r   .r  stringr  )restlollegit)patterns	kwd_attrskwd_patternsr  r  xxx_c           
      J   [         R                  " S[         R                  " 5       5      nU R                   H  nU R	                  [         R
                  " USS95         [         R                  " U[         R                  " U[         R                  " 5       /S9/S9n[         R                  " U5      n[         R                  " U// 5      nU R                  [        5         [        USS5        S S S 5        S S S 5        M     g ! , (       d  f       N= f! , (       d  f       M  = f)NrB   r   r  )rJ  r   )subjectr   r   re   )r   r   r  _MATCH_PATTERNSro   ro  MatchrM  r=  r  r   r=   r   rp   )r   name_xrJ  r   r   s        r   test_match_validation_pattern/ASTValidatorTests.test_match_validation_pattern	  s    #sxxz*++Gchhwq9:yy">>'MN 006TFB/&&z2FHf5 3 ;: , 32 ;:s%   BDD-D
DD
D"	r8   )Nre   rG   )PrW   r   rX   rY   r   r   r%   r&   r~  r7  r?  rG  rP  rT  rY  r^  rb  rf  rj  rn  rr  rz  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   requires_resourcer+  r   r   
constant_1
MatchValue	pattern_1
constant_x	pattern_xconstant_truer  pattern_truer   r  name_carterr  r0  MatchSequenceMatchMappingr	  
MatchClass	MatchStarMatchAsMatchOrr9  r<  rZ   r8   r!   r   r%  r%    s   2Z 2$* $60
d.(*2
:T


1E
	/A//(/(3;L
;?///.B(/
6"	((',+ O	
2
B2N5
!"
  u%
) &
) aJz*Ic"Jz*ILL&M%%d+L((8SXXZ0K 	MMchhsCIIK8#sxxzJ
	
 	MMchhsCHHJ7ciikJ
	
 	s||C()s||D)*s||I./8$3--h7893,,c.@.@.J-KLMN*m4ykBJ')Y)?f	
 	CKK
(CSXXZPQ	"	

 	MM#--
CDc388:V		
 	"	{	
 	")	
 	((23		
 	3==?"3rPR	
 	"#--/AR	
 	h#		
 	3==012!BYK Y	3+=+=e+DEF33==-./Rc*IEON6r!   r%  c                   r    \ rS rSrSrS rS rS rS rS r	S r
S	 r\R                  S
 5       rS rS rSrg)ConstantTestsi	  z$Tests on the ast.Constant node type.c                    [         R                  " S5      nUR                  S   R                  n[         R                  " US9n[         R
                  " XC5        XBR                  S   l        [        USS5      n0 n[        XV5        US   $ )Nzx = 123r   rE  ry   re   rB   )r   rz   r   r3   r   r  rp   re   )r   r3   r}   r   new_noder  r  s          r   compile_constantConstantTests.compile_constant	  sp    yy#yy|!!<<e,()%		!tZ0T#wr!   c                     U R                  [        5       nU R                  / SQ5        S S S 5        U R                  [	        WR
                  5      S5        g ! , (       d  f       N4= f)Nr  z%got an invalid type in Constant: list)r=   r@   rQ  r.   r  r  )r   r  s     r   test_validationConstantTests.test_validation-	  sH    y)R!!), *R\\*,ST *)s   A
A&c                     S SS[         S[        5       4 H=  nU R                  US9   U R                  U5      nU R	                  X!5        S S S 5        M?     g ! , (       d  f       MQ  = f)NFTr!   )const)r   r  ro   rQ  r  )r   rW  r3   s      r   test_singletonsConstantTests.test_singletons2	  sU    E43	DEE*--e4e+ +* E**s   #A
A&	c           	      J   Sn[        S15      n[        S5       H  nUS4n[        US15      nM     SSSSS	[        S
5      [        S5      UU4	nU H=  nU R                  US9   U R	                  U5      nU R                  Xe5        S S S 5        M?     g ! , (       d  f       MQ  = f)Nr   r   r   r;   rK   g     ^@y             ^@unicode   bytesr  r  rE  )r  r   r  ro   rQ  r.   )r   nested_tuplenested_frozensetr  r  r3   results          r   test_valuesConstantTests.test_values8	  s    $aS>1XE(!,L(*:A)>?  'Nk"

 EE*..u5  / +* **s   ##B
B"	c                    [         R                  " S5      nUR                  S   R                  S   n[         R                  " SS9n[         R
                  " X25        X1R                  S   R                  S'   U R                  [        5       n[        USS5        S S S 5        U R                  [        WR                  5      S5        g ! , (       d  f       N4= f)Nx = 1r   r   rE  r.  re   z6expression which can't be assigned to in Store context)r   rz   r   targetsr   r  r=   r   rp   r.   r  r  )r   r}   rH  
new_targetr  s        r   test_assign_to_constant%ConstantTests.test_assign_to_constantN	  s    yy!1%%a(\\*
*-",		!Qz*bD(F+ +G	
 +*s   C		
Cc                 |    [         R                  " S5      nU R                  [         R                  " U5      S5        g )Nz'docstring'
x = 1	docstring)r   rz   r.   r  r   s     r   r   ConstantTests.test_get_docstring]	  s,    yy-.**40+>r!   c                     [        USS5      n/ n[        R                  " U5       H@  nUR                  S:X  d  UR                  S:X  d  M%  UR	                  UR
                  5        MB     U$ )Nry   re   
LOAD_CONSTRETURN_CONST)rp   disget_instructionsopnamer  argval)r   r}   coconstsinstrs        r   get_load_constConstantTests.get_load_consta	  sZ     T:v.))"-E|||+u||~/Mell+ . r!   c                    / SQnSR                  U Vs/ s H  nSR                  U5      PM     sn5      nUS-  nUR                  [        S 45        [        R
                  " U5      nU R                  U R                  U5      U5        [        UR                  U5       Hy  u  pR[        U[        R                  5      (       d   [        R                  " U5      5       e[        R                  " US9n[        R                  " XeR                  5        Xel        M{     U R                  U R                  U5      U5        g s  snf )N)	NTF|   g       @y              @r\  r]  r  r  zx={!r}z
x = ...rE  )r%  r   r$  r   r   rz   r.   rv  rn   r   r   rX  ro  r   r  r3   )r   rt  rW  r  r}   r
  rP  s          r   test_load_constConstantTests.test_load_constk	  s    RyyfEfU(//%0fEFx&'yy,,T2F; !F3MFfcjj11C388F3CC1||%0Hh5#L	 4 	,,T2F; Fs   D>c                    [         R                  " S5      nUR                  S   R                  n[         R                  " SS9n[         R
                  " X2R                  5        X2l        [         R                  " SS9n[         R
                  " XBR                  5        XBl        U R                  [         R                  " U5      S5        g )Nr   r   r   rE  y              4@y      $@      4@)
r   rz   r   r3   r   r  r  r  r.   rt  )r   r}   binopnew_left	new_rights        r   r  ConstantTests.test_literal_eval	  s    yy!		!""<<b)(JJ/
LLs+	)[[1))%0(;r!   c                    [         R                  " SSS9R                  nU R                  UR                  S5        U R                  UR
                  S 5        [         R                  " SSS9R                  nU R                  UR                  S5        U R                  UR
                  S5        [         R                  " SSS9R                  nU R                  UR                  S5        U R                  UR
                  S 5        [         R                  " SSS9R                  nU R                  UR                  S	5        U R                  UR
                  S 5        g )
Nz"x"rg   r  rB   zu"x"r  zr"x"zb"x"   x)r   rz   r   r.   r3   rm   )r   r  s     r   test_string_kindConstantTests.test_string_kind	  s    IIe&)..#&&IIf6*//#&%IIf6*//#&&IIf6*//$'&r!   r8   N)rW   r   rX   rY   r  rQ  rT  rX  ra  rg  r  rv  r   rR  rz  r  r  rZ   r8   r!   r   rN  rN  	  sM    .U
,0,
? < <&<'r!   rN  c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S"r$g#)$EndPositionTestsi	  zTests for end position of AST nodes.

Testing end positions of nodes requires a bit of extra care
because of how LL parsers work.
c                 t    U R                  UR                  U5        U R                  UR                  U5        g rG   )r.   r   r   )r   r0   r   r   s       r   _check_end_posEndPositionTests._check_end_pos	  s.    ,,j900.Ar!   c                 P    U R                  [        R                  " X5      U5        g rG   )r.   r   get_source_segment)r   r:  r0   contents       r   _check_contentEndPositionTests._check_content	  s    //A7Kr!   c                 \    [         R                  " U5      R                  S   R                  $ )Nr   )r   rz   r   r3   r  s     r   _parse_valueEndPositionTests._parse_value	  s#     yy|  #)))r!   c                     SnU R                  U5      nU R                  XR                  S5        U R                  XR                  R                  S   S5        U R                  XR                  R                  S5        g )Nzlambda x, *y: Noner  r   rB   r   )r  r  r   r  r?   )r   r>  lams      r   r  EndPositionTests.test_lambda	  s`     "Axx0Axx}}Q/5Axx4r!   c                 D   [        S5      R                  5       n[        R                  " U5      R                  S   nU R                  USS5        U R                  XR                  S   S5        U R                  XR                  R                  S   S5        U R                  XR                  R                  S   R                  S5        U R                  XR                  R                  S5        U R                  XR                  R                  R                  S	5        g )
Nz
            def func(x: int,
                     *args: str,
                     z: float = 0,
                     **kwargs: Any) -> bool:
                return True
            r   r      zreturn Truezx: intr  zkwargs: AnyAny)
r   r   r   rz   r   r  r  r  
annotationr  r   r>  fdefs      r   test_func_defEndPositionTests.test_func_def	  s        	
 yy|  #D!R(Ayy|];Ayy~~a0(;Ayy~~a0;;UCAyy>Ayy995Ar!   c                    SnU R                  U5      nU R                  XR                  S5        U R                  XR                  S   R                  S5        U R                  XR                  S   R                  S5        g )Nzfunc(x, y=2, **kw)r  r   2r   kw)r  r  r  r  r3   r   r>  r  s      r   r  EndPositionTests.test_call	  si       #Ayy&1A}}Q/55s;A}}Q/55t<r!   c                     SnU R                  U5      nU R                  XR                  S5        U R                  USS5        g )Nzx[0]()zx[0]r   r  )r  r  r  r  r  s      r   test_call_noargs!EndPositionTests.test_call_noargs	  s=      #Ayy&1D!Q'r!   c                    [        S5      R                  5       n[        R                  " U5      R                  S   nU R                  USS5        U R                  XR                  S   S5        U R                  XR                  S   S5        g )Nz?
            class C(A, B):
                x: int = 0
        r   r;      r   Bz
x: int = 0)r   r   r   rz   r   r  r  rL  r   r>  cdefs      r   test_class_defEndPositionTests.test_class_def	  sy       UW 	
 yy|  #D!R(Azz!}c2Ayy|\:r!   c                     Sn[         R                  " U5      R                  S   nU R                  XR                  S   R
                  S5        g )Nz$class S(metaclass=abc.ABCMeta): passr   zabc.ABCMeta)r   rz   r   r  r  r3   r  s      r   test_class_kwEndPositionTests.test_class_kw	  s>    2yy|  #A}}Q/55}Er!   c                     [        S5      R                  5       n[        R                  " U5      R                  S   nU R                  USS5        U R                  UR                  SS5        g )Nzh
            x = """Some multi-line text.

            It goes on starting from same indent."""
        r   r   (   r   r   r   rz   r   r  r3   r   r>  r
  s      r   test_multi_line_str$EndPositionTests.test_multi_line_str	  s_       UW	 	

 1""1%FAr*FLL!R0r!   c                     [        S5      R                  5       n[        R                  " U5      R                  S   nU R                  USS5        U R                  UR                  SS5        g )NzB
            x = "first part" \
            "second part"
        r   r;   r  r  r  s      r   test_continued_str#EndPositionTests.test_continued_str	  s_       UW 	
 1""1%FAr*FLL!R0r!   c                 F   [        S5      R                  5       n[        R                  " U5      nUR                  S   nUR                  S   nUR                  S   nUR                  S   nUR                  S   nU R                  USS5        U R                  USS	5        U R                  US	S
5        U R                  USS5        U R                  USS5        U R                  XR                  S5        U R                  XR                  S   S5        U R                  XR                  S   R                  S5        U R                  XR                  S5        U R                  XR                  S   S5        U R                  XR                  S   R                  S5        g )Na  
            while True:
                pass

            if one():
                x = None
            elif other():
                y = None
            else:
                z = None

            for x, y in stuff:
                assert True

            try:
                raise RuntimeError
            except TypeError as e:
                pass

            pass
        r   r   r;   r   r   r  r  r  r  r      r  zx = Nonezother()x, yzraise RuntimeErrorr@   )r   r   r   rz   r   r  r  r  r  rH  handlersr   )r   r>  r   
while_loopif_stmtfor_looptry_stmt	pass_stmts           r   test_suitesEndPositionTests.test_suites	  sc      ( UW) 	
* iilXXa[
((1+88A;88A;HHQK	J1-GQ+Hb"-Hb!,Ir1-A7A||A
;A~~a055yAA7A}}Q/1EFA00388+Fr!   c                     SnU R                  U5      nUR                  S   R                  nU R                  XS5        g )Nzx = f"abc {x + y} abc"r   zx + y)r  r  r3   r  r   r>  fstrr}  s       r   test_fstringEndPositionTests.test_fstring$
  s:    $  #A$$Ag.r!   c                     [        S5      R                  5       nU R                  U5      nUR                  S   R                  nU R                  USS5        U R                  XR                  S5        U R                  XR                  S5        g )Nz
            f"""Some multi-line text.
            {
            arg_one
            +
            arg_two
            }
            It goes on..."""
        r   r   r   arg_onearg_two)	r   r   r  r  r3   r  r  r  r  r  s       r   test_fstring_multi_line(EndPositionTests.test_fstring_multi_line*
  s|       UW 	
   #A$$E1a(Azz95A{{I6r!   c                     [        S5      R                  5       n[        R                  " U5      R                  S   nU R                  USS5        U R                  UR                  S   SS5        g )NzT
            from x.y.z import (
                a, b, c as c
            )
        r   r   r   r;   r   )r   r   r   rz   r   r  r   )r   r>  r  s      r   test_import_from_multi_line,EndPositionTests.test_import_from_multi_line:
  sc       UW	 	

 iil"CA&CIIaL!R0r!   c                    SnSn[        S5      R                  5       n[        U R                  XU45      u  pEnU R	                  XR
                  S5        U R	                  XR
                  R                  S5        U R	                  X%R                  R                  S5        U R	                  X%R                  R                  S5        U R	                  X6R                  R                  S   R                  S	5        U R	                  X6R                  R                  S
   R                  S5        U R                  USS5        g )Nzf()[1, 2] [0]zx[ a.b: c.d]zN
            x[ a.b: f () ,
               g () : c.d
              ]
        z	f()[1, 2]z1, 2za.bzc.dr   f ()r   g ()r   )r   r   mapr  r  r3   r   r   r   eltsr  )r   s1s2smi1i2r   s          r   test_slicesEndPositionTests.test_slicesD
  s       UW	 	
 **RRL9
B+6B7B6B6Ba 0 6 6?Ba 0 6 6?B1%r!   c                 :   [        S5      R                  5       nU R                  U5      nU R                  USS5        U R	                  XR
                  S5        U R	                  XR                  S5        U R	                  XR                  R
                  S5        g )NzF
            (1 * 2 + (3 ) +
                 4
            )
        r;   r  4z1 * 2 + (3 )3)r   r   r  r  r  r  r  )r   r>  r}  s      r   
test_binopEndPositionTests.test_binopU
  s       UW	 	

 !!!$E1a(A{{C0Azz>:Azz//5r!   c                     [        S5      R                  5       n[        R                  " U5      R                  S   R
                  nU R                  USS5        U R                  XR                  S   S5        g )Nz{
            if (one_condition and
                    (other_condition or yet_another_one)):
                pass
        r   r;   ,   r   z"other_condition or yet_another_one)	r   r   r   rz   r   r  r  r  r  )r   r>  bops      r   r  EndPositionTests.test_boolopa
  sh       UW	 	

 iil"''CB'Azz!}.RSr!   c                 
   SnSnSn[        S5      R                  5       n[        U R                  XX445      u  pVpxU R	                  XS5        U R	                  X&S5        U R	                  X7S5        U R                  USS	5        g )
Nzx = () ;z	x = 1 , ;zx = (1 , 2 ) ;z?
            x = (
                a, b,
            )
        r-  z1 ,z(1 , 2 )r   r   )r   r   r  r  r  r  )	r   r  r  s3r  t1t2t3tms	            r   test_tuplesEndPositionTests.test_tuplesk
  s       UW	 	
 T..0@ABD)BE*BJ/B1%r!   c                     SnU R                  U5      nU R                  XU5        U R                  XR                  S   S5        g )Nzfunc(x. y .z)r   zx. y .z)r  r  r  r  s      r   test_attribute_spaces&EndPositionTests.test_attribute_spacesz
  s?      #AQ'Ayy|Y7r!   c                    Sn[         R                  " U5      R                  S   R                  nU R	                  [        U5      R                  S5        U R                  XS5        SU-   n[         R                  " U5      R                  S   R                  R                  nU R	                  [        U5      R                  S5        U R                  X2S5        g )Nz( ( ( a + b ) ) )r   r   za + bawait )r   rz   r   r3   r.   r   rW   r  )r   r>  r  r  s       r   test_redundant_parenthesis+EndPositionTests.test_redundant_parenthesis
  s    IIaLa &&a))73A'*\IIbMq!''--a))73B7+r!   c                 &   SnU H  u  p#U R                  U5         [        R                  " U5      R                  S   R                  nU R                  [        U5      R                  U5        U R                  X$U5        SU-   n[        R                  " U5      R                  S   R                  R                  nU R                  [        U5      R                  U5        U R                  XTU5        S S S 5        M     g ! , (       d  f       GM  = f)N))z( ( ( a ) ) ) ( )r  )z( ( ( a ) ) ) ( b )r  )z( ( ( a ) ) ) [ b ]r   )z( ( ( a ) ) ) . br  r   r  )	ro   r   rz   r   r3   r.   r   rW   r  )r   rN  r>  ry  r  r  s         r   (test_trailers_with_redundant_parenthesis9EndPositionTests.test_trailers_with_redundant_parenthesis
  s    
 DAaIIaL%%a(..  a!1!115##A!,\IIbM&&q)//55  a!1!115##B1- !  s   CD  
D	c                    SnSnU R                  U5      nU R                  U5      nU R                  XR                  S   S5        U R                  XR                  S   S5        U R                  XR                  S   S5        U R                  X$R                  S   S	5        U R                  X$R                  S   S
5        g )Nz[{}, {1, }, {1, 2,} ]z{a: b, f (): g () ,}r   z{}r   z{1, }r;   z{1, 2,}r  r  )r  r  r  r  r  )r   r  r  c1c2s        r   test_displaysEndPositionTests.test_displays
  s    $#r"r"B
D1B
G4B
I6B
F3B		!f5r!   c                    [        S5      R                  5       nU R                  U5      nU R                  USS5        U R	                  XR
                  S   R                  S5        U R	                  XR                  R
                  S   R                  S5        U R	                  XR                  R
                  S   R                  S   S5        U R	                  XR                  R
                  S   R                  S5        g )	Nza
            x = [{x for x, y in stuff
                  if cond.x} for stuff in things]
        r;   %   r   thingsstuffzcond.xr  )
r   r   r  r  r  
generatorsrI  eltifsrH  )r   r>  cmps      r   test_comprehensions$EndPositionTests.test_comprehensions
  s       UW 	
 "CB'A~~a055x@Aww11!4997CAww11!488;XFAww11!4;;VDr!   c                     [        S5      R                  5       n[        R                  " U5      R                  S   nU R                  XR                  S   R                  S5        U R                  XR                  S   R                  S5        g )NzT
            async def f():
                yield x
                await y
        r   zyield xr   zawait y)r   r   r   rz   r   r  r3   r  s      r   test_yield_await!EndPositionTests.test_yield_await
  ss       UW	 	

 yy|  #Ayy|119=Ayy|119=r!   c                     [        S5      R                  5       n[        S5      R                  5       nU R                  U5      nU R                  [        R
                  " XR                  5      U5        g )NzD
            x = (
                a, b,
            ) + ()
        z;
            (
                a, b,
            )
        )r   r   r  r.   r   r  r  )r   s_origs_tupler}  s       r   test_source_segment_multi*EndPositionTests.test_source_segment_multi
  sk       UW	 	
    UW	 	
 !!&)//

CWMr!   c                     [        S5      R                  5       nSn[        R                  " U5      R                  S   nU R                  [        R                  " XR                  S   SS9U5        g )Nuf   
            class C:
                def fun(self) -> None:
                    "ЖЖЖЖЖ"
        u/       def fun(self) -> None:
        "ЖЖЖЖЖ"r   Tpaddedr   r   r   rz   r   r.   r  )r   r
  s_methodr  s       r   test_source_segment_padded+EndPositionTests.test_source_segment_padded
  sf       UW	 	
 Iyy %%a(""699Q<Ex	
r!   c                    Sn[         R                  " U5      R                  u  p#pEnU R                  XS5        U R                  XS5        U R                  XS5        U R                  XS5        U R                  XS5        g )Nz!v = 1
w = 1
x = 1
y = 1z = 1
zv = 1zw = 1rd  zy = 1zz = 1)r   rz   r   r  )r   r>  r  rA  rB   r   r   s          r   test_source_segment_endings,EndPositionTests.test_source_segment_endings
  sp    7		!))aAA'*A'*A'*A'*A'*r!   c                     [        S5      R                  5       nSn[        R                  " U5      R                  S   nU R                  [        R                  " XR                  S   SS9U5        g )Nzb
            class C:
              	  def fun(self) -> None:
              	      pass
        z+  	  def fun(self) -> None:
  	      passr   Tr  r  )r   r>  r  r  s       r   test_source_segment_tabs)EndPositionTests.test_source_segment_tabs
  sb       UW	 	

 Iyy|  #//99Q<MxXr!   c                 D   Sn[         R                  " U5      R                  u  p#nU R                  XS5        U R                  XS5        U R                  XS5        Sn[         R                  " U5      R                  S   nU R                  XUR	                  5       5        g )Nz3def f():
  pass
def g():  pass
def h():
  pass
zdef f():
  passzdef g():  passzdef h():
  passz"def f():
  a = 1  b = 2
  c = 3
r   )r   rz   r   r  rstrip)r   r>  r!  r  hs        r   test_source_segment_newlines-EndPositionTests.test_source_segment_newlines
  s    J))A,##aA"45A"45A"675IIaLa A!((*-r!   c                    Sn[         R                  " U5      R                  u  p#pEU?U?U?U?U R                  [         R                  " X5      5        U R                  [         R                  " X5      5        U R                  [         R                  " X5      5        U R                  [         R                  " X5      5        g )Nzv = 1
w = 1
x = 1
y = 1
)	r   rz   r   r(   r   r)   r   ra   r  )r   r>  r  rA  rB   r   s         r    test_source_segment_missing_info1EndPositionTests.test_source_segment_missing_info
  s    0YYq\&&
aHLL#0067#0067#0067#0067r!   r8   N)%rW   r   rX   rY   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r!  rZ   r8   r!   r   r  r  	  s    BL*
5B =(;F
11*GX/7 1&"
6T&8,."	6
E>N

+	Y	.
8r!   r  c                       \ rS rSrS rSrg)BaseNodeVisitorCasesi  c                   ^  " U4S jSU R                   5      n[        R                  " [        S5      5      nU" 5       n/ m[        R
                  " SS9 n[        R                  " SS[        5        UR                  U5        S S S 5        U R                  T/ SQ5        U R                  W Vs/ s H  n[        UR                  5      PM     sn/ S	Q5        g ! , (       d  f       N[= fs  snf )
Nc                   R   > \ rS rSrU 4S jrU 4S jrU 4S jrU 4S jrU 4S jrSr	g)	=BaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitori  c                 V   > TR                  UR                  SUR                  45        g )Nr   )r  r(   r2  r   r   logs     r   	visit_NumGBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_Num      

DKK78r!   c                 V   > TR                  UR                  SUR                  45        g )Nr   r  r(   r>  r)  s     r   	visit_StrGBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_Str	  r-  r!   c                 V   > TR                  UR                  SUR                  45        g )Nr   r/  r)  s     r   visit_BytesIBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_Bytes  s    

DKK$&&9:r!   c                 V   > TR                  UR                  SUR                  45        g )Nr   )r  r(   r3   r)  s     r   visit_NameConstantPBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_NameConstant  s    

DKKDEr!   c                 B   > TR                  UR                  SS45        g )Nr   .)r  r(   r)  s     r   visit_EllipsisLBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_Ellipsis  s    

DKKS9:r!   r8   N)
rW   r   rX   rY   r+  r0  r3  r6  r9  rZ   )r*  s   r   Visitorr'    s"    99;F; ;r!   r;  z            i = 42
            f = 4.25
            c = 4.25j
            s = 'string'
            b = b'bytes'
            t = True
            n = None
            e = ...
            Tr+  r-  r   ))r   r   r9   )r;   r   r3  )r   r   r4  )r   r   r.  )r   r   r]  )r  r   T)r   r   N)r  r   .)+visit_Num is deprecated; add visit_Constantr9  r<  r9  r<  r9  z+visit_Str is deprecated; add visit_Constantr;  z-visit_Bytes is deprecated; add visit_Constantr;  4visit_NameConstant is deprecated; add visit_Constantr=  z0visit_Ellipsis is deprecated; add visit_Constant)visitor_classr   rz   r   r   r   r   r   visitr.   r  r?  )r   r;  r   visitorr@  rA  r*  s         @r   test_old_constant_nodes,BaseNodeVisitorCases.test_old_constant_nodes  s    	;d(( 	;  ii 	 	
 )$$D1T##Hb2DEMM# 2 			
 	%)*TS^T*	
! 21" +s   .C/C*
C'r8   N)rW   r   rX   rY   rA  rZ   r8   r!   r   r$  r$    s    @
r!   r$  c                   ,    \ rS rSr\R
                  rSrg)NodeVisitorTestsiG  r8   N)rW   r   rX   rY   r   NodeVisitorr>  rZ   r8   r!   r   rD  rD  G  s    OOMr!   rD  c                   P    \ rS rSr\R
                  rS rS rS r	S r
S rS rSrg	)
NodeTransformerTestsiK  c                     [         R                  " [        U5      5      n[         R                  " [        U5      5      nU" 5       n[         R                  " UR	                  U5      5      nU R                  Xu5        g rG   )r   rz   r   r  r?  assertASTEqual)r   tranformer_classinitial_codeexpected_codeinitial_astexpected_ast
tranformer
result_asts           r   assertASTTransformation,NodeTransformerTests.assertASTTransformationN  sY    ii| 45yy!67%'
..z/?/?/LM
J5r!   c                 b    SnSn " S S[         R                  5      nU R                  X1U5        g )Nzdef func(arg) -> SomeType: ...zdef func(arg): ...c                   6    \ rS rSrS\R
                  4S jrSrg)ENodeTransformerTests.test_node_remove_single.<locals>.SomeTypeRemoveri]  r   c                 J    U R                  U5        UR                  S:X  a  g U$ )NSomeType)generic_visitr   r  s     r   
visit_NamePNodeTransformerTests.test_node_remove_single.<locals>.SomeTypeRemover.visit_Name^  s$    ""4(77j(r!   r8   N)rW   r   rX   rY   r   r   rY  rZ   r8   r!   r   SomeTypeRemoverrU  ]      sxx r!   r[  r   NodeTransformerrQ  )r   r  r   r[  s       r   test_node_remove_single,NodeTransformerTests.test_node_remove_singleW  s0    /'	c11 	 	$$_HEr!   c                 b    SnSn " S S[         R                  5      nU R                  X1U5        g )NzM
        def func(arg):
            print(arg)
            yield arg
        7
        def func(arg):
            print(arg)
        c                   6    \ rS rSrS\R
                  4S jrSrg)ENodeTransformerTests.test_node_remove_from_list.<locals>.YieldRemoveris  r   c                 |    U R                  U5        [        UR                  [        R                  5      (       a  g U$ rG   )rX  r   r3   r   r  r  s     r   
visit_ExprPNodeTransformerTests.test_node_remove_from_list.<locals>.YieldRemover.visit_Exprt  s-    ""4(djj#))44r!   r8   N)rW   r   rX   rY   r   r   rf  rZ   r8   r!   r   YieldRemoverrd  s  r\  r!   rh  r]  )r   r  r   rh  s       r   test_node_remove_from_list/NodeTransformerTests.test_node_remove_from_listf  s4    
	3.. 	 	$$\Br!   c                 b    SnSn " S S[         R                  5      nU R                  X1U5        g )Nz0
        class DSL(Base, kw1=True): ...
        zE
        class DSL(Base, kw1=True, kw2=True, kw3=False): ...
        c                   6    \ rS rSrS\R
                  4S jrSrg)BNodeTransformerTests.test_node_return_list.<locals>.ExtendKeywordsi  r   c                     U R                  U5        UR                  S:X  aW  U[        R                  " S[        R                  " S5      5      [        R                  " S[        R                  " S5      5      /$ U$ )Nkw1kw2Tkw3F)rX  r  r   rL  r   r  s     r   visit_keywordPNodeTransformerTests.test_node_return_list.<locals>.ExtendKeywords.visit_keyword  s^    ""4(88u$E3<<+=>E3<<+>? 
 r!   r8   N)rW   r   rX   rY   r   rL  rr  rZ   r8   r!   r   ExtendKeywordsrm    s    #++ r!   rt  r]  )r   r  r   rt  s       r   test_node_return_list*NodeTransformerTests.test_node_return_list|  s4    		S00 		 	$$^8Dr!   c                 b    SnSn " S S[         R                  5      nU R                  X1U5        g )Nrb  z5
        def func(arg):
            log(arg)
        c                   6    \ rS rSrS\R
                  4S jrSrg)9NodeTransformerTests.test_node_mutate.<locals>.PrintToLogi  r   c                     U R                  U5        [        UR                  [        R                  5      (       a+  UR                  R
                  S:X  a  SUR                  l        U$ )Nprintr*  )rX  r   r  r   r   r   r  s     r   
visit_CallDNodeTransformerTests.test_node_mutate.<locals>.PrintToLog.visit_Call  sD    ""4(dii22tyy||w7N#(DIILr!   r8   NrW   r   rX   rY   r   r  r|  rZ   r8   r!   r   
PrintToLogry    r\  r!   r  r]  r   r  r   r  s       r   test_node_mutate%NodeTransformerTests.test_node_mutate  s4    
	,, 	 	$$Zx@r!   c                 b    SnSn " S S[         R                  5      nU R                  X1U5        g )Nrb  zH
        def func(arg):
            logger.log(arg, debug=True)
        c                   6    \ rS rSrS\R
                  4S jrSrg):NodeTransformerTests.test_node_replace.<locals>.PrintToLogi  r   c           
         U R                  U5        [        UR                  [        R                  5      (       a  UR                  R
                  S:X  a  [        R                  " [        R                  " [        R                  " S[        R                  " 5       S9S[        R                  " 5       S9UR                  [        R                  " S[        R                  " S5      5      /S9$ U$ )	Nr{  loggerr  r*  )r9  r  debugT)r  r  r  )rX  r   r  r   r   r   r  r  r  r  rL  r   r  s     r   r|  ENodeTransformerTests.test_node_replace.<locals>.PrintToLog.visit_Call  s    ""4(dii22tyy||w7N88 ]]HHX388:>!& #

 "YY"%++gs||D7I"J!K  r!   r8   Nr~  r8   r!   r   r  r    s    sxx r!   r  r]  r  s       r   test_node_replace&NodeTransformerTests.test_node_replace  s4    
	,, 	 	$$Zx@r!   r8   N)rW   r   rX   rY   r   r^  r>  rQ  r_  ri  ru  r  r  rZ   r8   r!   r   rG  rG  K  s0    ''M6FC,E*A&Ar!   rG  c                   N    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSrg)ASTConstructorTestsi  z2Test the autogenerated constructors for AST nodes.c                 .   [         R                  " 5       nU R                  UR                  / 5        U R                  UR                  / 5        U R                  [        S5         [         R                  " US9nS S S 5        U R                  [        WS5      5        U R                  UR                  / 5        [         R                  " SUS9nU R                  UR                  S5        U R                  UR                  / 5        g ! , (       d  f       N= f)NzDFunctionDef\.__init__ missing 1 required positional argument: 'name'r  r   r   )r   r  )r   r  r.   r  r  r   r   r<  rz  re  r#   r   )r   r  r   s      r   test_FunctionDef$ASTConstructorTests.test_FunctionDef  s    }}B'))2.""S
 ??-D	

 	v./,,b1E5E*,,b1
 
s   $D
Dc                    [         R                  " S5      nU R                  UR                  S5        U R	                  UR
                  [         R                  5        [         R                  " S[         R                  " 5       5      nU R                  UR                  S5        U R	                  UR
                  [         R                  5        [         R                  " S[         R                  " 5       S9nU R                  UR                  S5        U R	                  UR
                  [         R                  5        U R                  [        S5         [         R                  " 5       nS S S 5        g ! , (       d  f       g = f)NrB   r  z;Name\.__init__ missing 1 required positional argument: 'id')r   r   r.   r   r   r  r  r0  Delr   r   )r   r   name2name3s       r   test_expr_context%ASTConstructorTests.test_expr_context  s    xx}#&dhh1ciik*3'eii3#''),3'eii1""J
 HHJE	
 
 
s   E00
E>c                      " S S[         R                  5      nU" 5       nU R                  X!5        U R                  UR                  0 5        g )Nc                       \ rS rSrSrg)GASTConstructorTests.test_custom_subclass_with_no_fields.<locals>.NoIniti  r8   NrV   r8   r!   r   NoInitr    r\   r!   r  )r   r   r   r.   r<   )r   r  r  s      r   #test_custom_subclass_with_no_fields7ASTConstructorTests.test_custom_subclass_with_no_fields  s=    	SWW 	 hc*r*r!   c                      " S S[         R                  5      nU" 5       nU R                  [        5         UR                    S S S 5        U" SS9nU R                  UR                  S5        g ! , (       d  f       N1= f)Nc                       \ rS rSrSrSrg)BASTConstructorTests.test_fields_but_no_field_types.<locals>.Fieldsi  r]   r8   N)rW   r   rX   rY   r$   rZ   r8   r!   r   Fieldsr    s    Gr!   r  r   r  )r   r   r=   r>   r]   r.   )r   r  r  s      r   test_fields_but_no_field_types2ASTConstructorTests.test_fields_but_no_field_types  s[    	SWW 	 h~.EE /qk" /.s   A..
A<c                      " S S[         R                  5      nU" 5       nU R                  UR                  S 5        U" SS9nU R	                  UR                  S5        g )Nc                   <    \ rS rSr% SrS\S-  0rSr\S-  \S'   Sr	g)AASTConstructorTests.test_fields_and_types.<locals>.FieldsAndTypesi  r  r]   Nr8   )
rW   r   rX   rY   r$   r  _field_typesr]   r  rZ   r8   r!   r   FieldsAndTypesr    s#    Gt,L AsTz r!   r  r   r  )r   r   r  r]   r.   )r   r  r  s      r   test_fields_and_types)ASTConstructorTests.test_fields_and_types  sL    	!SWW 	!
 ceeT"q!"r!   c                      " S S[         R                  5      nU" SSS9nU R                  UR                  S5        U R                  UR                  S5        U R                  [        S5         U" SS9nS S S 5        g ! , (       d  f       g = f)	Nc                       \ rS rSrSrSrg);ASTConstructorTests.test_custom_attributes.<locals>.MyAttrsi  r]   rW  r8   N)rW   r   rX   rY   _attributesrZ   r8   r!   r   MyAttrsr    s    $Kr!   r  r   r;   r  z8MyAttrs.__init__ got an unexpected keyword argument 'c'.r   )r  )r   r   r.   r]   rW  r   r   )r   r  r  s      r   test_custom_attributes*ASTConstructorTests.test_custom_attributes  sw    	%cgg 	% Q""""G
 A,C	
 
 
s   /A??
Bc                 ^    " S S[         R                  5      nU R                  [        S5         U" 5       nS S S 5        U R	                  [
        5         WR                    S S S 5        U" SS9nU R                  UR                  S5        g ! , (       d  f       N[= f! , (       d  f       NB= f)Nc                        \ rS rSrSrS\0rSrg)UASTConstructorTests.test_fields_and_types_no_default.<locals>.FieldsAndTypesNoDefaulti  r  r]   r8   N)rW   r   rX   rY   r$   r  r  rZ   r8   r!   r   FieldsAndTypesNoDefaultr    s    G:Lr!   r  zOFieldsAndTypesNoDefault\.__init__ missing 1 required positional argument: 'a'\.r   r  )r   r   r   r   r=   r>   r]   r.   )r   r  r  s      r    test_fields_and_types_no_default4ASTConstructorTests.test_fields_and_types_no_default  s    	&cgg 	& ""^
 *+C	

 ~.EE /%*"
 

 /.s   BB
B
B,c                     " S S[         R                  5      nU R                  [        S5         U" 5       nS S S 5        U R	                  WR
                  S 5        U R	                  UR                  S 5        U" SSS9nU R                  UR
                  S5        U R                  UR                  S5        g ! , (       d  f       N= f)Nc                   P    \ rS rSr% SrS\S-  0rSr\S-  \S'   Sr	\S-  \S'   Sr
g)LASTConstructorTests.test_incomplete_field_types.<locals>.MoreFieldsThanTypesi   r  r]   NrW  r8   )rW   r   rX   rY   r$   r  r  r]   r  rW  rZ   r8   r!   r   MoreFieldsThanTypesr     s1     Gt,L AsTz  AsTz r!   r  z;Field 'b' is missing from MoreFieldsThanTypes\._field_typesr   r;   r  )r   r   r   r   r  r]   rW  r.   )r   r  r  s      r   test_incomplete_field_types/ASTConstructorTests.test_incomplete_field_types  s    	!#'' 	! ""J
 &'C	

 	ceeT"ceeT"!A+""
 
s   B88
Cc                      " S S[         R                  5      nU" 5       nU R                  UR                  S 5        U R	                  UR
                  / 5        g )Nc                   T    \ rS rSr% Sr\S-  \\   S.rSr	\S-  \
S'   \\   \
S'   Srg)EASTConstructorTests.test_complete_field_types.<locals>._AllFieldTypesi3  r  Nr]   rW  r8   )rW   r   rX   rY   r$   r  r,   r  r  r]   r  rZ   r8   r!   r   _AllFieldTypesr  3  s0     G!$t$s)<L AsTz CyLr!   r  )r   r   r  r]   r.   rW  )r   r  r  s      r   test_complete_field_types-ASTConstructorTests.test_complete_field_types2  sB    	SWW 	 ceeT"#r!   r8   N)rW   r   rX   rY   r  r  r  r  r  r  r  r  r  r  rZ   r8   r!   r   r  r    s2    <2&+#	###&$r!   r  c                   ,    \ rS rSrS rS rS rS rSrg)ModuleStateTestsi@  c                     SnSnSn[        XU[        R                  S9n[        XBU5      nU R                  U[        R
                  5        g )Nzx + 1ry   rg   )flags)rp   r   rq   r   typesCodeType)r   r  filenamer  ru   s        r   check_ast_module!ModuleStateTests.check_ast_moduleD  sI     44s7H7HI x40dENN3r!   c                 F   [         R                  " [        R                  SS 5         [        R                  S	 SS Kn[        R                  S	 SS KnU R                  5         S S S 5        AA[         R                  " 5         U R                  5         g ! , (       d  f       N6= f)N_astr   )r   	swap_itemsysmodulesr  r  r`   )r   ast1r[  s      r   test_reload_module#ModuleStateTests.test_reload_moduleQ  sp    s{{FD9F#F#!!# :  :9s   ;B
B c                   ^ [        5       mU4S jn[        R                  " [        R                  SS 5         [        R                  S	 [        R
                  " [        SU5         U R                  5         U R                  S[        R                  5        SS K	nU R                  UT5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nc                 .   > T[         R                  U '   T$ rG   )r  r  )r   r  r  lazy_mods      r   	my_import4ModuleStateTests.test_sys_modules.<locals>.my_importh  s     (CKKOr!   r  
__import__r   )r  r   r  r  r  r  r   r  assertNotInr  r  )r   r  r  r  s      @r   test_sys_modules!ModuleStateTests.test_sys_modulesc  s     8	 s{{FD9F#""8\9E%%'  5 dH- F :9 FE :9s$   .C&AB>-C>
C	C
Cc                 j    [        S5      n[        R                  " U5      nU R                  US5        g )Nap  
            import _ast
            import ast
            import gc
            import sys
            import types

            # Create _ast.AST subclasses instances and call PyAST_Check()
            ast_tree = compile('x+1', '<string>', 'eval',
                               flags=ast.PyCF_ONLY_AST)
            code = compile(ast_tree, 'string', 'eval')
            if not isinstance(code, types.CodeType):
                raise AssertionError

            # Unloading the _ast module must not crash.
            del ast, _ast
            del sys.modules['ast'], sys.modules['_ast']
            gc.collect()
        r   )r   r   run_in_subinterpr.   )r   r  r   s      r   test_subinterpreter$ModuleStateTests.test_subinterpretery  s5       & &&t,a r!   r8   N)	rW   r   rX   rY   r  r  r  r  rZ   r8   r!   r   r  r  @  s    4 $.,!r!   r  c                       \ rS rSrS rSrg)ASTMainTestsi  c                    Sn[         R                  " [         R                  " U5      SS9n[        R                  " 5        n[
        R                  R                  US5      n[        USSS9 nUR                  U5        S S S 5        [        R                  " SS	U5      u  pgS S S 5        U R                  WR                  S
5        U R                  UR                  5       UR                  R!                  S5      R                  5       5        U R                  UR"                  S5        g ! , (       d  f       N= f! , (       d  f       N= f)Nzprint(1, 2, 3)r   r  ztest_module.pyrA  r  r  z-mr   r!   utf8r   )r   ro  rz   r   temp_dirr  r  r%  r&  writer   run_python_until_endr.   err
splitlinesoutdecoderc)r   r  r   tmp_dirr  r!  r   r6  s           r   test_cli_file_input ASTMainTests.test_cli_file_input  s    88CIIdOA6!Www||G-=>Hhg6! 7"77eXNFC	 " 	#&,,.v0F0Q0Q0ST# 76 "!s$   ,D:-D)?"D:)
D7	3D::
Er8   N)rW   r   rX   rY   r  rZ   r8   r!   r   r  r    s    $r!   r  c                 \    [         R                  " U 5      [         R                  " U5      :H  $ rG   )r   ro  )r  r  s     r   comparer    s    88D>SXXe_,,r!   c                      \ rS rSr\R
                  " 5       \R                  " 5       \R                  " 5       \R                  " 5       \R                  " 5       \R                  " 5       \R                  " 5       \R                  " 5       \R                  " 5       \R                  " 5       \R                  " 5       \R                   " 5       S.r\R$                  " 5       \R&                  " 5       \R(                  " 5       S.rS rS rS r\R2                  " S5      \R2                  " S5      4S jrS	 rS
 rS rS rS rS r S r!S r"S r#S r$S r%Sr&g)ASTOptimizationTestsi  )+-r   /%z<<z>>|r>  &z//z**)~r  r  c                 P    [         R                  " [         R                  " US9/S9$ )NrE  r  )r   r   r   )r   r%   s     r   	wrap_exprASTOptimizationTests.wrap_expr  s    zzt 4566r!   c                 ,    [         R                  " U/S9$ )Nr  )r   r   )r   	statements     r   wrap_statement#ASTOptimizationTests.wrap_statement  s    zz	{++r!   c                    [         R                  " USS9n[         R                  " USS9nU R                  [        XB5      [         R                  " U5       S[         R                  " U5       35        U R                  [        XR5      [         R                  " U5       S[         R                  " U5       35        U R                  [        XS5      [         R                  " U5       S[         R                  " U5       35        g )Nr   r   r   z must equal z must not equal )r   rz   r   r  ro  rz  )r   r  non_optimized_targetoptimized_targetnon_optimized_treeoptimized_trees         r   
assert_astASTOptimizationTests.assert_ast  s     YYtb94!4 	&=xx,-.lxx*+,.	
 	N9xx,-..>xx*+,.	
 	N6xx()*,xx'(*	
r!   r   c                 F    [         R                  " X R                  U   US9$ )Nr  )r   r   r}  )r   r  r  r  s       r   create_binop!ASTOptimizationTests.create_binop  s    99$::g+>eLLr!   c                    SnU R                   R                  5       nU H  nX-  nU R                  U R                  U5      5      nU R                  [        R
                  " [        U5      S95      nU R                  UUUS9   U R                  XEU5        S S S 5        M     SnU R                  U R                  S[        R                  " [        R
                  " SS9/S9[        R
                  " SS95      5      nU R                  [        R
                  " [        U5      5      5      nU R                  XU5        g ! , (       d  f       GM/  = f)	Nz1 %s 1rE  result_coder  r  z(1,) * 3r   r   r  r   )
r}  r  r  r  r   r   rg   ro   r	  r  )r   r  	operatorsr  r  r  r  s          r   test_folding_binop'ASTOptimizationTests.test_folding_binop  s#   JJOO%	B)K#'>>$2C2CB2G#H #~~cllkAR.ST'%9!1  
 CST   #~~d.?.?SYYUXUaUahiUjTkElnqnznz  BC  oD  /E   F>>#,,tDz*BC4DE s   D>>
E	c                 j  ^  SnT R                   R                  5       nU 4S jnU Hx  nX-  nT R                  U" U5      5      nT R                  [        R                  " [        U5      5      5      nT R                  UUUS9   T R                  XVU5        S S S 5        Mz     g ! , (       d  f       M  = f)Nz%s1c                 p   > [         R                  " TR                  U    [         R                  " S5      S9$ )Nr   r  r  )r   r  rh  r   )r  r   s    r   create_unaryopAASTOptimizationTests.test_folding_unaryop.<locals>.create_unaryop  s%    ;;$,,w"7aQQr!   r  )rh  r  r  r   r   rg   ro   r	  )r   r  r  r  r  r  r  r  s   `       r   test_folding_unaryop)ASTOptimizationTests.test_folding_unaryop  s    LL%%'		R B)K#'>>.2D#E #~~cll4;L.MN'%9!1  
 CST  
 s   B##
B2	c                 @  ^ Sn[         R                  " 5       [         R                  " 5       S.m[         R                  " 5       [         R                  " 5       S.nU4S jnTR                  5        H  nX-  nU R                  U" U5      5      nU R                  [         R                  " [         R                  " S5      X$   /[         R                  " SS9/S95      nU R                  UUUS	9   U R                  XVU5        S S S 5        M     g ! , (       d  f       M  = f)
Nznot (1 %s (1,)))inis)r  r  c                    > [         R                  " [         R                  " 5       [         R                  " [         R                  " SS9TU    /[         R
                  " [         R                  " SS9/S9/S9S9$ )Nr   rE  r  r  opscomparatorsr  )r   r  r  r  r   r  )r  r  s    r   create_notop;ASTOptimizationTests.test_folding_not.<locals>.create_notop  sY    ;;#'')S[[\\*w'( YYS\\-B,CDE6  r!   r   r[  rE  r   r  )r   r  IsIsNotNotInr  r  r  r   ro   r	  )	r   r  opt_operatorsr#  r  r  r  r  r  s	           @r   test_folding_not%ASTOptimizationTests.test_folding_not
  s     &&(&&(
	
 ))+))+

	 .."B)K#'>>,r2B#C #~~a}7H6IX[XdXdkoXpWqr  '%9!1  
 CST  # s   .D
D	c                    SnU R                  [        R                  " [        R                  " SS9[        R                  " 5       [        R
                  " [        R                  " SS9/S9S95      nU R                  [        R                  " [        R                  " [        R                  " SS9SS	9/S
95      nU R                  XU5        g )Nz'%s' % (a,)z%srE  r]   )r   r  r  s   )r3   
conversion)r  )
r  r   r   r   Modr  r   	JoinedStrFormattedValuer	  r   r  r  r  s       r   test_folding_format(ASTOptimizationTests.test_folding_format*  s    #~~II\\-779iichh#&6%78: 
  >>MM&&SXX-=#N
 	4DEr!   c                     SnU R                  [        R                  " [        R                  " S5      /S95      nU R                  [        R                  " SS95      nU R	                  XU5        g )Nz(1,)r   r  r[  rE  )r  r   r  r   r	  r1  s       r   test_folding_tuple'ASTOptimizationTests.test_folding_tuple>  sQ    #~~ciicll1o=N.OP>>#,,T*BC4DEr!   c                 d   SnS[         R                  " 5       4S[         R                  " 5       4/nSS[         R                  S4SS[         R                  [        S	15      4/nU H  u  pEpgU H  u  pU R                  [         R                  " [         R                  " S	5      U	/U" [         R                  " S	5      /S
9/S95      n
U R                  [         R                  " [         R                  " S	5      U	/[         R                  " US9/S95      nU R                  XXE4-  X5        M     M     g )Nz
1 %s %s1%sr  znot in[]r[  {}r   r  r   rE  )
r   r  r'  r  r  r  r  r  r   r	  )r   r  r  bracesr  r  non_optimized_comparatoroptimized_comparatorr  r   r  r  s               r   test_folding_comparator,ASTOptimizationTests.test_folding_comparatorF  s	   CFFH%#))+'>?	#sxx&#sww	1#/
 LRGD1%'+~~ckkatf!9Q?P!Q R7 ($ $(>>#++atf!$4H!I J3 $  D'8 8:Na & LRr!   c                    SnSS[         R                  S4SS[         R                  [        S15      4/nU GH  u  p4pVU R	                  [         R
                  " [         R                  " S[         R                  " 5       S	9U" [         R                  " S5      /S
9[         R                  " 5       /S95      nU R	                  [         R
                  " [         R                  " S[         R                  " 5       S	9[         R                  " US9[         R                  " 5       /S95      nU R                  XU4-  Xx5        GM	     g )Nzfor _ in %s1%s: passr8  r9  r[  r:  r;  r   r6  r  r  )rH  rI  r   rE  )r   r  r  r  r  r   r   r0  r   r=  r	  )	r   r  r<  r  r  ast_clsoptimized_iterr  r  s	            r   test_folding_iter&ASTOptimizationTests.test_folding_iterY  s    %#sxx&#sww	1#/

 5;0D#'#6#6swwxx3CIIK83<<?"34hhj\8 $ 
  $22377xx3CIIK8\\7hhj\4   OOD%=02FY 5;r!   c           
      (   SnU R                  [        R                  " [        R                  " [        R                  " SS9/S9[        R                  " SS9S95      nU R                  [        R                  " SS95      nU R                  XU5        g )Nz(1,)[0]r   rE  r  r   )r3   r   )r  r   r   r  r   r	  r1  s       r   test_folding_subscript+ASTOptimizationTests.test_folding_subscriptn  sl    #~~MM		10E/F Gs||bcOde 
  >>#,,Q*?@4DEr!   c                 P   SnU R                  S5      nSS[        R                  4SS[        R                  4SS[        R                  4/nU H  u  pEnX-  nU R                  [        R                  " S[        R                  " 5       [        R                  " 5       /U" U[        R                  " S	5      S
9/S95      nU R                  [        R                  " S[        R                  " 5       [        R                  " 5       /U" XRS
9/S95      n	U R                  XyU5        M     g )Nzdef foo[%s = 1 + 1](): passr  r  **PP*TsTsr   r;   r   default_value)r   r  r   rM  )r  r   TypeVar	ParamSpecTypeVarTupler  r<  r  r=  r   r	  
r   r  unoptimized_binopunoptimized_type_paramsr   r   
type_paramr  r  r  s
             r   'test_folding_type_param_in_function_def<ASTOptimizationTests.test_folding_type_param_in_function_defx  s    , --c2#s{{#C'D#**+#
 '>"D
+K#22((*!+S\\RS_!U V	  $(#6#6((*!+!W X	$  OOK?OP% '>r!   c                     SnU R                  S5      nSS[        R                  4SS[        R                  4SS[        R                  4/nU H  u  pEnX-  nU R                  [        R                  " S[        R                  " 5       /U" U[        R                  " S	5      S
9/S95      nU R                  [        R                  " S[        R                  " 5       /U" XRS
9/S95      n	U R                  XyU5        M     g )Nzclass foo[%s = 1 + 1]: passr  r  rJ  rK  rL  rM  r   r;   rN  )r   r   rM  )
r  r   rP  rQ  rR  r  r  r=  r   r	  rS  s
             r   $test_folding_type_param_in_class_def9ASTOptimizationTests.test_folding_type_param_in_class_def  s    , --c2#s{{#C'D#**+#
 '>"D
+K#22((*!+S\\RS_!U V  $(#6#6((*!+!W X$  OOK?OP! '>r!   c                    SnU R                  S5      nSS[        R                  4SS[        R                  4SS[        R                  4/nU H  u  pEnX-  nU R                  [        R                  " [        R                  " S[        R                  " 5       S	9U" U[        R                  " S
5      S9/[        R                  " SS9S95      nU R                  [        R                  " [        R                  " S[        R                  " 5       S	9U" XRS9/[        R                  " SS9S95      n	U R                  XyU5        M     g )Nztype foo[%s = 1 + 1] = 1r  r  rJ  rK  rL  rM  r   r  r;   rN  r   rE  )r   rM  r3   )r  r   rP  rQ  rR  r  	TypeAliasr   r0  r   r	  rS  s
             r   %test_folding_type_param_in_type_alias:ASTOptimizationTests.test_folding_type_param_in_type_alias  s   ) --c2#s{{#C'D#**+#
 '>"D
+K#22U		<!+S\\RS_!U V,,Q/  $(#6#6U		<!+!W X,,Q/$  OOK?OP! '>r!   r8   N)'rW   r   rX   rY   r   r   r  MultDivr.  LShiftRShiftBitOrBitXorBitAndFloorDivPowr}  Invertr  USubrh  r  r  r	  r   r  r  r  r)  r2  r5  r?  rD  rG  rW  rZ  r^  rZ   r8   r!   r   r  r    s   WWYWWYXXZWWYWWYjjljjlYY[ZZ\ZZ\llnggiE  ZZ\XXZXXZG7,
4 *-aQ MF.U&U@F(Fb&Z*FQ<Q8Qr!   r  __main__)6r   r   rc  ro  r  r  rB  r  ra  r  unittestr   r^   	functoolsr   r   r0  ImportErrorr  r   test.support.import_helperr   test.supportr   r   test.support.ast_helperr	   test.test_ast.utilsr
   test.test_ast.snippetsr   r   r   r   r   r   TestCaser   rT  rm  r%  rN  r  r$  rD  rG  r  rR  r  r  r  r  rW   mainr8   r!   r   <module>rv     s   
   
  	 	 
         : 1 0 ( 
E7!! E7P MM!! MM`{=h'' {=|c	6)) c	6L@'H%% @'F`8x(( `8FB
 B
J$+X->-> $rA<)=x?P?P rAj}$(++ }$@ 	O!x(( O! O!d$8$$ $"-eQ8,, eQP	 zMMO ym  s   F* *F65F6