
    <ej                         d dl Z d dlmZmZ d dlZd dlZd dlmZ d Zd Z	 G d de          Z
 G d d	ej                  Zed
k    r ej                     dS dS )    N)combinationsproduct)BytecodeTestCasec                 p    t          j        d|  d          }i }t          ||           |d         j        S )Nz=
        def f(x):
            match x:
                case z#:
                    pass
        f)textwrapdedentexec__code__)patternsource	namespaces      */usr/lib/python3.11/test/test_peepholer.py compile_pattern_with_fast_localsr   	   sP    _	 	 	 	 F IS>""    c                     d}t          j        |           D ]}|j        |k    r|dz  }t          | d          r| j        } | j        D ]%}t          |d          r|t          ||          z  }&|S )Nr      r   co_code)disget_instructionsopnamehasattrr   	co_constscount_instr_recursively)r   r   countinstrcs        r   r   r      s    E%a((  <6!!QJEq* J[ 8 81i   	8,Q777ELr   c                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Z ej        d          d             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%d# Z&d$ Z'd%S )&TestTranformsc           
      .   t          t          j        |                    }d |D             }|D ]}d|j        vr||j                 }|j        dv r4|                     |j         d|j         d|j         d|j                    |j        dv r?|j        dk    r4|                     |j         d|j         d|j         d|j                    d|j        v r=d|j        v r4|                     |j         d|j         d|j         d|j                    d S )	Nc                     i | ]
}|j         |S  )offset.0r   s     r   
<dictcomp>z4TestTranforms.check_jump_targets.<locals>.<dictcomp>(   s    AAA55<AAAr   JUMP_)JUMP_ABSOLUTEJUMP_FORWARDz at z
 jumps to RETURN_VALUE_OR_POPJUMP_IF_)listr   r   r   argvalfailr#   )selfcodeinstructionstargetsr   tgts         r   check_jump_targetsz TestTranforms.check_jump_targets&   s   C06677AALAAA! 	D 	DEel**%,'Cz>>>		U\ C Cu| C C&)jC C69jC C D D D  AAA
n,,		U\ C Cu| C C&)jC C69jC C D D D EL((Z3:-E-E		U\ C Cu| C C&)jC C69jC C D D D	D 	Dr   c                 R   	 t          j        |          }t          t          j        |                    }t	          d |D                       }t          d |D                       }|                     |d           |                     |t          |j	                             d S )Nc              3   &   K   | ]}|d          V  dS r   Nr"   r%   ts     r   	<genexpr>z-TestTranforms.check_lnotab.<locals>.<genexpr>A   &      00A1Q4000000r   c              3   &   K   | ]}|d          V  dS r8   r"   r9   s     r   r;   z-TestTranforms.check_lnotab.<locals>.<genexpr>B   r<   r   r   )
r   _get_code_objectr-   findlinestartsminmaxassertGreaterEqual
assertLesslenr   )r0   r1   lnotabmin_bytecodemax_bytecodes        r   check_lnotabzTestTranforms.check_lnotab;   s    :#D))c(..// 00000000000000a000c$,&7&788888r   c                     d }|                      |d           |                      |d           |                      |d           |                     |d           |                     |           d S )Nc                     | dk    s~ d S d S )N   r"   xs    r   unotz%TestTranforms.test_unot.<locals>.unotK   s    66AA 6r   	UNARY_NOTPOP_JUMP_FORWARD_IF_FALSEPOP_JUMP_BACKWARD_IF_FALSEPOP_JUMP_FORWARD_IF_TRUEassertNotInBytecodeassertInBytecoderH   )r0   rN   s     r   	test_unotzTestTranforms.test_unotI   s    	 	 	 	  {333  'BCCC  'CDDDd$>???$r   c                     dD ]q\  }}}|                      |          5  t          |dd          }|                     |||           |                     |           d d d            n# 1 swxY w Y   rd S )N))z
not a is bIS_OPr   )znot a is not brX   r   )z
not a in bCONTAINS_OPr   )znot a not in brY   r   line single)subTestcompilerU   rH   )r0   r[   cmp_opinvertr1   s        r   test_elim_inversion_of_is_or_inz-TestTranforms.test_elim_inversion_of_is_or_inT   s    % 		( 		( D&& 4(( ( (tR22%%dFF;;;!!$'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (		( 		(s   >A))A-	0A-	c                    d }d }d }|d f|df|dffD ]u\  }}|                      |          5  |                     |d           |                     |d|           |                     |           d d d            n# 1 swxY w Y   vd	 }|                     |d           |                     |dd            |                     |           d S )
Nc                      d } d } | S Nr"   rL   s    r   r   z0TestTranforms.test_global_as_constant.<locals>.fb   s    AAHr   c                  
    d} | S )NTr"   rL   s    r   gz0TestTranforms.test_global_as_constant.<locals>.gf   s    AHr   c                  
    d} | S )NFr"   rL   s    r   hz0TestTranforms.test_global_as_constant.<locals>.hi   s    AHr   TF)funcLOAD_GLOBAL
LOAD_CONSTc                      	 d S re   r"   r"   r   r   r   z0TestTranforms.test_global_as_constant.<locals>.fs   s
    ?4r   )r^   rT   rU   rH   )r0   r   rg   ri   rj   elems         r   test_global_as_constantz%TestTranforms.test_global_as_constant`   s\   	 	 		 	 		 	 	 t9q$i!U< 	( 	(JD$4(( ( (((}===%%dL$???!!$'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (
	 	 	 	  M222at444!s   AA??B	B	c                     d }dD ]}|                      ||           dD ]}|                     ||           |                     |           d S )Nc                       	 	 re   )r-   r"   r   r   r   z'TestTranforms.test_while_one.<locals>.f}   s    r   )rl   POP_JUMP_IF_FALSE)JUMP_BACKWARDrS   )r0   r   rn   s      r   test_while_onezTestTranforms.test_while_one{   s}    	 	 	 8 	. 	.D$$Q----& 	+ 	+D!!!T****!r   c                 B   dD ]\  }}|                      |          5  t          |dd          }|                     ||           |                     |d           |                     |d           |                     |           d d d            n# 1 swxY w Y   d S )N))za, = a,rl   )za, b = a, bSWAP)za, b, c = a, b, crv   rZ   r\   r]   BUILD_TUPLEUNPACK_SEQUENCEr^   r_   rU   rT   rH   r0   r[   rn   r1   s       r   test_pack_unpackzTestTranforms.test_pack_unpack   s     
	( 
	(JD$
 4(( ( (tBx00%%dD111((}===((/@AAA!!$'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (
	( 
	(s   A)BB	B	c           	         dD ]\  }}|                      |          5  t          |dd          }|                     |d|           |                     |d           |                     |           d d d            n# 1 swxY w Y   t          t          t          t          d                              dd          }|                     |d           d t          j	        |          D             }| 
                    t          |          d	           |                     |           d
 }|                     |           d S )N))z	a = 1,2,3r   rK      )z("a","b","c")abr   )za,b,c = 1,2,3r}   )z(None, 1, None)Nr   N)z((1, 2), 3, 4)r   rK   r~      rZ   r\   r]   rl   rw   '  c                 (    g | ]}|j         d k    |S )rl   r   r$   s     r   
<listcomp>zETestTranforms.test_folding_of_tuples_of_constants.<locals>.<listcomp>   s.     ? ? ?!&!=!= !=!=!=r   rK   c                      g d f d S )N)dr   r   rK   r~   r               	   r   r   rK   r~   r   r   r   r   r   r   r   r   rK   r~   r   r   r   r   r   r   r   r   rK   r~   r   r   r   r   r   r   r   r   rK   r~   r   r   r   r   r   r   r   r   rK   r~   r   r   r   r   r   r   r   r   rK   r~   r   r   r   r   r   r   r   r   rK   r~   r   r   r   r   r   r   r   r   rK   r~   r   r   r   r   r   r   r   r   rK   r~   r   r   r   r   r   r   r"   r"   r   r   craterzATestTranforms.test_folding_of_tuples_of_constants.<locals>.crater   s*           r   )r^   r_   rU   rT   rH   reprtupleranger   r   assertEqualrD   )r0   r[   rn   r1   load_constsr   s         r   #test_folding_of_tuples_of_constantsz1TestTranforms.test_folding_of_tuples_of_constants   s    	( 	(JD$ 4(( ( (tBx00%%dL$???((}===!!$'''	( ( ( ( ( ( ( ( ( ( ( ( ( ( ( tE%,,//00H==  }555? ?#*>t*D*D ? ? ?[))1---$
	 	 	 	&!!!!!   AA>>B	B	c                    dD ]\  }}|                      |          5  t          |dd          }|                     |d|           |                     |d           |                     |           d d d            n# 1 swxY w Y   d S )N))za in [1,2,3]r}   )za not in ["a","b","c"]r   )za in [None, 1, None]r   )za not in [(1, 2), 3, 4]r   rZ   r\   r]   rl   
BUILD_LISTry   rz   s       r   "test_folding_of_lists_of_constantsz0TestTranforms.test_folding_of_lists_of_constants   s     	( 	(JD$ 4(( ( (tR22%%dL$???((|<<<!!$'''	( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	(r   c           	          dt          h d          fdt          h d          fdt          dd h          fdt          h d          fd	t          h d          ffD ]\  }}|                     |
          5  t          |dd          }|                     |d           |                     |d|           |                     |           d d d            n# 1 swxY w Y   d }d }|                      |d                     |                      |d                      |                     |           |                      |d                      |                      |d                     |                     |           d S )Nza in {1,2,3}   r   rK   r~   za not in {"a","b","c"}>   r   r   r   za in {None, 1, None}r   za not in {(1, 2), 3, 4}>   r   r~   r   za in {1, 2, 3, 3, 2, 1}rZ   r\   r]   	BUILD_SETrl   c                 
    | dv S Nr   r"   r   s    r   r   z:TestTranforms.test_folding_of_sets_of_constants.<locals>.f   s    	>!r   c                 
    | dvS r   r"   r   s    r   rg   z:TestTranforms.test_folding_of_sets_of_constants.<locals>.g   s    I%%r   r~   r   )	frozensetr^   r_   rT   rU   rH   
assertTrue)r0   r[   rn   r1   r   rg   s         r   !test_folding_of_sets_of_constantsz/TestTranforms.test_folding_of_sets_of_constants   s    Yyyy112%y'A'AB#Y4y%9%9:&	...(A(AB&	)))(<(<= 	( 	(JD$ 4(( ( (tR22(({;;;%%dL$???!!$'''	( ( ( ( ( ( ( ( ( ( ( ( ( ( (	" 	" 	"	& 	& 	& 	!AAaDD!!!!AAaDD!!!!!s   8ACC	C	c                 >   dD ]\  }}|                      |          5  t          |dd          }|                     |d|           t          j        |          D ]/}|                     |j                            d                     0|                     |           d d d            n# 1 swxY w Y   t          ddd          }|                     |dd           |                     |dd	           |                     |           t          d
dd          }|                     |dd           | 	                    ddz  |j
                   |                     |           t          ddd          }|                     |dd           | 	                    ddz  |j
                   |                     |           t          ddd          }|                     |dd           | 	                    ddz  |j
                   |                     |           d S )N))z	a = 2+3+4r   )z"@"*4z@@@@)za="abc" + "def"abcdef)za = 3**4Q   )za = 3*4   )z	a = 13//4r~   )za = 14%4rK   )za = 2+3r   )za = 13-4r   )za = (12,13)[1]   )za = 13 << 24   )za = 13 >> 2r~   )z
a = 13 & 7r   )z
a = 13 ^ 7
   )z
a = 13 | 7   rZ   r\   r]   rl   BINARY_za=2+"b"rK   r   za="x"*10000r   rM   z	a=1<<1000i  r   z	a=2**1000)r^   r_   rU   r   r   assertFalser   
startswithrH   assertNotInr   )r0   r[   rn   r1   r   s        r   #test_folding_of_binops_on_constantsz1TestTranforms.test_folding_of_binops_on_constants   sm    	( 	(JD$" 4(( ( (tR22%%dL$??? 1$77 I IE$$U\%<%<Y%G%GHHHH!!$'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( y"h//dL!444dL#666$ }b(33dL%888UDN333${B11dL$777D$.111${B11dL$777D$.111$s   BB,,B0	3B0	c                 p   t          ddd          }|                     |dd           |                     |d           |                     |           t          ddd          }|                     |dd           |                     |d           |                     |           t          d	dd          }|                     |dd
           |                     |d           |                     |           t          ddd          }|                     |d           |                     |           d S )Nz"foo"[0]r\   r]   rl   r   BINARY_SUBSCRu	   "a￿"[1]u   ￿u	   "𒍅"[0]u   𒍅z	"fuu"[10])r_   rU   rT   rH   )r0   r1   s     r   test_binary_subscr_on_unicodez+TestTranforms.test_binary_subscr_on_unicode  sB   z2x00dL#666  777$*B99dL(;;;  o666$ ("h77dL,???  777$ {B11dO444$r   c                 @   dD ]\  }}|                      |          5  t          |dd          }|                     |d|           t          j        |          D ]/}|                     |j                            d                     0|                     |           d d d            n# 1 swxY w Y   d }t          j        |          D ]/}|                     |j                            d                     0|                     |           dD ]\  }}}|                      |          5  t          |dd          }|                     |d|           |                     ||           |                     |           d d d            n# 1 swxY w Y   d S )	N))z-0.5g      )z-0.0       )z
-(1.0-1.0)r   )z-0r   )z~-2r   )z+1r   rZ   r\   r]   rl   UNARY_c                      dS )Nr   r"   r"   r   r   negzerozDTestTranforms.test_folding_of_unaryops_on_constants.<locals>.negzero?  s    :r   ))z-"abc"abcUNARY_NEGATIVE)z~"abc"r   UNARY_INVERT)	r^   r_   rU   r   r   r   r   r   rH   )r0   r[   rn   r1   r   r   r   s          r   %test_folding_of_unaryops_on_constantsz3TestTranforms.test_folding_of_unaryops_on_constants.  sL   
 	( 	(JD$ 4(( ( (tR22%%dL$??? 1$77 H HE$$U\%<%<X%F%FGGGG!!$'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (	 	 	 )'22 	@ 	@EU\44X>>????'"""#
 	( 	(D$ 4(( ( (tR22%%dL$???%%dF333!!$'''	( ( ( ( ( ( ( ( ( ( ( ( ( ( (		( 	(s%   BB,,B0	3B0	2AFF	F	c                     d }|                      |dd            d t          j        |          D             }|                     t	          |          d           |                     |           d S )Nc                     | S re   r"   rL   s    r   r   z/TestTranforms.test_elim_extra_return.<locals>.fS  s    Hr   rl   c                 (    g | ]}|j         d k    |S r*   r   r$   s     r   r   z8TestTranforms.test_elim_extra_return.<locals>.<listcomp>V  .     = = =U"\^;; ;;;r   r   )rT   r   r   r   rD   rH   r0   r   returnss      r   test_elim_extra_returnz$TestTranforms.test_elim_extra_returnQ  s    	 	 	  L$777= =c&:1&=&= = = =Wq)))!r   zVFollowing gh-92228 the return has two predecessors and that prevents jump elimination.c                 :   d }|                      |           |                     |d           |                     |d           d t          j        |          D             }|                     t          |          d           |                     |           d S )Nc                     | r|n|S re   r"   )cond
true_valuefalse_values      r   r   z1TestTranforms.test_elim_jump_to_return.<locals>.f_  s    "& %JJ$&r   r)   r(   c                 (    g | ]}|j         d k    |S r   r   r$   s     r   r   z:TestTranforms.test_elim_jump_to_return.<locals>.<listcomp>f  r   r   rK   )r5   rT   r   r   r   rD   rH   r   s      r   test_elim_jump_to_returnz&TestTranforms.test_elim_jump_to_return[  s    	& 	& 	& 	"""  N333  O444= =c&:1&=&= = = =Wq)))!r   c                 `    d }|                      |           |                     |           d S )Nc                  p    t           r t          st          rt                       d S d S t	                       d S re   )r   r   dfoobazr"   r   r   r   z6TestTranforms.test_elim_jump_to_uncond_jump.<locals>.fm  s@      EEEEE  r   r5   rH   r0   r   s     r   test_elim_jump_to_uncond_jumpz+TestTranforms.test_elim_jump_to_uncond_jumpk  sA    	 	 	 	"""!r   c                 `    d }|                      |           |                     |           d S )Nc                  J    | r t           st          rt                      } | d S d S re   )r   r   r   r   s    r   r   z7TestTranforms.test_elim_jump_to_uncond_jump2.<locals>.fz  sA      A	      r   r   r   s     r   test_elim_jump_to_uncond_jump2z,TestTranforms.test_elim_jump_to_uncond_jump2x  sA    	 	 	 	"""!r   c                    d }|                      |           |                     |           |                     t          |d          d           d }|                      |           |                     |           |                     t          |d          d           d }|                      |           |                     |           |                     |d           |                     |d           |                     |d           d }|                      |           |                     |           |                     |d           |                     |d           |                     |d	           d S )
Nc                     | o|o|S re   r"   r   s      r   r   z7TestTranforms.test_elim_jump_to_uncond_jump3.<locals>.f  s    W1 r   JUMP_IF_FALSE_OR_POPrK   c                     | p|p|S re   r"   r   s      r   r   z7TestTranforms.test_elim_jump_to_uncond_jump3.<locals>.f  s    V! r   JUMP_IF_TRUE_OR_POPc                     | r|p|S re   r"   r   s      r   r   z7TestTranforms.test_elim_jump_to_uncond_jump3.<locals>.f  s    W1 r   rP   c                     | s|o|S re   r"   r   s      r   r   z7TestTranforms.test_elim_jump_to_uncond_jump3.<locals>.f  s    V! r   rR   )r5   rH   r   r   rT   rU   r   s     r   test_elim_jump_to_uncond_jump3z,TestTranforms.test_elim_jump_to_uncond_jump3  s   	 	 	 	"""!04JKKQOOO	 	 	 	"""!04IJJANNN	 	 	 	"""!  $:;;;a!6777a!<===	 	 	 	"""!  $9:::a!7888a!;<<<<<r   c                    d }|                      |d           |                      |d           d t          j        |          D             }|                     t	          |          d           |                     |           d S )Nc                     | rdS |rdS 	 dS )Nr   rK   r~   r"   )cond1cond2s     r   r   z5TestTranforms.test_elim_jump_after_return1.<locals>.f  s     QQQQqr   r)   r(   c                 (    g | ]}|j         d k    |S r   r   r$   s     r   r   z>TestTranforms.test_elim_jump_after_return1.<locals>.<listcomp>  r   r   r   )rT   r   r   assertLessEqualrD   rH   r   s      r   test_elim_jump_after_return1z*TestTranforms.test_elim_jump_after_return1  s    	 	 	 	  N333  O444= =c&:1&=&= = = =S\\1---!r   c                 b    d }|                      |d           |                     |           d S )Nc                      dd} | S )NreturnrK   c                      d S re   r"   r"   r   r   rg   zBTestTranforms.test_make_function_doesnt_bail.<locals>.f.<locals>.g  s    r   )r   rK   r"   )rg   s    r   r   z7TestTranforms.test_make_function_doesnt_bail.<locals>.f  s       Hr   	BINARY_OP)rT   rH   r   s     r   test_make_function_doesnt_bailz,TestTranforms.test_make_function_doesnt_bail  sC    	 	 	 	  K000!r   c                    g d}|D ]}|                      |          5  t          |dd          }t          j        |          D ]}|                     |j                            d                     |                     |j                            d                     |                     |j                            d                     |                     |           d d d            n# 1 swxY w Y   d S )N)	z3 * -5z-3 * 5z2 * (3 * 4)z(2 * 3) * 4z
(-1, 2, 3)z
(1, -2, 3)z
(1, 2, -3)z(1, 2, -3) * 6z:lambda x: x in {(3 * -5) + (-1 - 6), (1, -2, 3) * 2, None})er\   r]   r   r   BUILD_)r^   r_   r   r   r   r   r   rH   )r0   exprsr   r1   r   s        r   test_constant_foldingz#TestTranforms.test_constant_folding  sH   

 

 

  	( 	(A"" ( (q"h// 1$77 H HE$$U\%<%<X%F%FGGG$$U\%<%<Y%G%GHHH$$U\%<%<X%F%FGGGG!!$'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	(s   CC00C4	7C4	c                 ~    d }|                      t          |d          d           |                     |           d S )Nc                  ,    t           t          t          fv S re   )rM   r   r   r"   r   r   containtestz7TestTranforms.test_in_literal_list.<locals>.containtest  s    A;r   r   r   r   r   rH   )r0   r   s     r   test_in_literal_listz"TestTranforms.test_in_literal_list  sL    	 	 	0lKKQOOO+&&&&&r   c                 ~    d }|                      t          |d          d           |                     |           d S )Nc                  (    t           t          fD ]} d S re   r   r   rL   s    r   forloopz8TestTranforms.test_iterate_literal_list.<locals>.forloop  s"    V   r   r   r   r   )r0   r   s     r   test_iterate_literal_listz'TestTranforms.test_iterate_literal_list  sN    	 	 	 	0,GGKKK'"""""r   c                 r    d }|                       |            d           |                     |           d S )Nc                      	 dS )NTFr   r"   r"   r   r   r   z=TestTranforms.test_condition_with_binop_with_bools.<locals>.f      qr   r   )r   rH   r   s     r   $test_condition_with_binop_with_boolsz2TestTranforms.test_condition_with_binop_with_bools  sI    	 	 	 	a   !r   c                 r    d }|                       |d                     |                     |           d S )Nc                     | rnndS dS )NTFr"   rL   s    r   r   z3TestTranforms.test_if_with_if_expression.<locals>.f  s       t5r   T)r   rH   r   s     r   test_if_with_if_expressionz(TestTranforms.test_if_with_if_expression  sG    	 	 	 	$   !r   c                 6    d }|                      |           d S )Nc                     	 dS )Nr   r~   r"   rL   s    r   r   z+TestTranforms.test_trailing_nops.<locals>.f  r   r   )rH   r   s     r   test_trailing_nopsz TestTranforms.test_trailing_nops  s-    	 	 	 	!r   c                 >   d }|                      t          |d          d           d }|                      t          |d          d           d }|                      t          |d          d           d }|                      t          |d          d           d S )Nc                  $    d t           D             S )Nc                 0    g | ]}t          |          }|S r"   r   r%   rM   ys      r   r   z[TestTranforms.test_assignment_idiom_in_comprehensions.<locals>.listcomp.<locals>.<listcomp>  "    111!1Q44QA111r   r   r"   r   r   listcompzGTestTranforms.test_assignment_idiom_in_comprehensions.<locals>.listcomp      11q1111r   FOR_ITERr   c                  $    d t           D             S )Nc                 0    h | ]}t          |          }|S r"   r	  r
  s      r   	<setcomp>zYTestTranforms.test_assignment_idiom_in_comprehensions.<locals>.setcomp.<locals>.<setcomp>  r  r   r   r"   r   r   setcompzFTestTranforms.test_assignment_idiom_in_comprehensions.<locals>.setcomp  r  r   c                  $    d t           D             S )Nc                 2    i | ]}t          |          }||S r"   r	  r
  s      r   r&   z[TestTranforms.test_assignment_idiom_in_comprehensions.<locals>.dictcomp.<locals>.<dictcomp>  s$    444QaddAq444r   r   r"   r   r   dictcompzGTestTranforms.test_assignment_idiom_in_comprehensions.<locals>.dictcomp  s    44!4444r   c                  $    d t           D             S )Nc              3   8   K   | ]}t          |          }|V  d S re   r	  r
  s      r   r;   zYTestTranforms.test_assignment_idiom_in_comprehensions.<locals>.genexpr.<locals>.<genexpr>  s,      11!1Q44QA111111r   r   r"   r   r   genexprzFTestTranforms.test_assignment_idiom_in_comprehensions.<locals>.genexpr
  r  r   )r   r   )r0   r  r  r  r  s        r   'test_assignment_idiom_in_comprehensionsz5TestTranforms.test_assignment_idiom_in_comprehensions   s    	2 	2 	20:FFJJJ	2 	2 	20*EEqIII	5 	5 	50:FFJJJ	2 	2 	20*EEqIIIIIr   c                    d}g t          dd          t          dd          t          dd          t          t          d          t          d           fd	          }g t          d
d          dd}|D ]\  }}|D ]\  }}t          t          |          dz             D ]}t	          ||          D ]}	dd                    |	          z   |z   |z   |z   }
|                     |
|          5  |
|z  }t          |
dd|i          }|                     ||d|
           d d d            n# 1 swxY w Y   d S )Nz-+ #0)r\   1234u   абвгsra)  i.duioxX)|EJ@g|EJ	duifegFEGinffegFEG)r\   130)r\   .z.0z.2)r\   .40)r%  r'  r   %r\   )fmtvaluez % (x,)rM   zfmt = )	r   floatr   rD   r   joinr^   evalr   )r0   flags	testcaseswidth_precsr*  suffixwidthprecrspecr)  s1s2s                r   test_format_combinationsz&TestTranforms.test_format_combinations  s   
-u55
]H--
 2K@@
 eEllU5\\M2H==	
	
_&;<<

 

 ' 	B 	BME6* B Bts5zzA~.. B BA ,UA 6 6 B B!BGGDMM1E9D@6I!\\c\?? B B!$uB!%&7&7&7#u!F!FB ,,R[[[AAAB B B B B B B B B B B B B B BBBB	B 	Bs   15D22D69D6c                    d }|                       |d          d           |                       |dd          d           |                       |dd          d           |                       |dd          d           |                       |d	d          d
           |                       |dd          d           |                       |d	d          d           |                       |dd          d           |                       |dd          d           |                       |dd          d           |                       |ddd          d           d S )Nc           	      (   d t          t          |                    D             }t          |          dk    rd|d         z   dz   }ndd                    |          z   dz   }t          | d| t	          t          ||                              S )	Nc                     g | ]
}d |dz    S )rM   r   r"   )r%   is     r   r   zBTestTranforms.test_format_misc.<locals>.format.<locals>.<listcomp>'  s"    :::!I!II:::r   r   (r   z,)z, )z % )r   rD   r,  r-  dictzip)r)  valuesvarsargss       r   formatz.TestTranforms.test_format_misc.<locals>.format&  s    ::uS[['9'9:::D4yyA~~T!W}t+TYYt__,s23++T++T#dF2C2C-D-DEEEr   stringzx = %s!r  z	x = 1234!zx = %d!zx = %x!zx = 4d2!zx = %f!zx = 1234.000000!r   zx = 1234.5678901!zx = 1234.567890!zx = %s%% %%%%zx = 1234% %%z%% %sz
x = %% %s!zx = %s, y = %dr   "   zx = 12, y = 34)r   )r0   rD  s     r   test_format_misczTestTranforms.test_format_misc%  s   	F 	F 	F 	))8444	400+>>>	400+>>>	400*===	4002DEEE	<88:MNNN	<88:LMMM	<88+FFF66GGG	733\BBB 0"b99;KLLLLLr   c                    |                      t          d          5  t          d           d d d            n# 1 swxY w Y   |                      t          d          5  t          dddd           d d d            n# 1 swxY w Y   |                      t          d          5  t          d	d
di           d d d            n# 1 swxY w Y   |                      t          d          5  t          dd
di           d d d            n# 1 swxY w Y   |                      t          d          5  t          dd
di           d d d            n# 1 swxY w Y   |                      t          d          5  t          dd
di           d d d            n# 1 swxY w Y   |                      t          d          5  t          dd
di           d d d            n# 1 swxY w Y   |                      t          d          5  t          dd
di           d d d            n# 1 swxY w Y   |                      t          d          5  t          dd
di           d d d            n# 1 swxY w Y   |                      t          d          5  t          dd
di           d d d            n# 1 swxY w Y   |                      t          d          5  t          ddg d           d d d            n# 1 swxY w Y   |                      t          d          5  t          ddddgd           d d d            d S # 1 swxY w Y   d S )Nz&not enough arguments for format stringz	'%s' % ()z4not all arguments converted during string formattingz'%s' % (x, y)r   rK   rM   r  zincomplete formatz'%s%' % (x,)rM   r  z'%s%%%' % (x,)z'%s%z' % (x,)zunsupported format characterz'%s%z' % (x, 5)z"a real number is required, not strz'%d' % (x,)r  z!an integer is required, not floatz'%x' % (x,)g
ףp=J@zan integer is required, not strzmust be real number, not strz'%f' % (x,)z'%s, %s' % (x, *y)r~   )assertRaisesRegex	TypeErrorr-  
ValueErrorr0   s    r   test_format_errorsz TestTranforms.test_format_errors:  s?   ##I<> > 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ##IJL L 	4 	4"2"2333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 ##J0CDD 	. 	.#t---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.##J0CDD 	0 	0!C;///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0##I<> > 	/ 	/3+...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ ##J0NOO 	1 	1"S$K000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1##I/STT 	/ 	/f...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/##I/RSS 	0 	0g///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0##I/PQQ 	/ 	/f...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/##I/MNN 	/ 	/f...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/##I<> > 	: 	:%QR'8'8999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: ##IJL L 	> 	>%QaV'<'<===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   8<<A>>BB$CC
C)DDD.EEE3FFF8GGG=HH #H I!!I%(I%J&&J*-J*K,,K03K0L55L9<L9c                 8    d }|                      |d           d S )Nc                     | |}} | |} }d S re   r"   r   s     r   r   z5TestTranforms.test_static_swaps_unpack_two.<locals>.fZ  s    aqAaqAAAr   rv   rT   r   s     r   test_static_swaps_unpack_twoz*TestTranforms.test_static_swaps_unpack_twoY  s/    	 	 	 	  F+++++r   c                 8    d }|                      |d           d S )Nc                 N    | ||}}} | ||}}} | ||}} }| ||} }}| ||}} }| ||} }}d S re   r"   r   s      r   r   z7TestTranforms.test_static_swaps_unpack_three.<locals>.f`  sT    A!qAA!qAA!qAA!qAA!qAA!qAAAr   rv   rQ  r   s     r   test_static_swaps_unpack_threez,TestTranforms.test_static_swaps_unpack_three_  s/    	 	 	 	  F+++++r   c                     t          ddd          D ]d\  }}}d| d| d| d}|                     |          5  t          |          }|                     |d           d d d            n# 1 swxY w Y   ed S )	N_a_b_cz{'a': z, 'b': z, 'c': }rv   )r   r^   r   rT   )r0   r   r   r   r   r1   s         r   test_static_swaps_match_mappingz-TestTranforms.test_static_swaps_match_mappingi  s    tT400 	7 	7GAq!999!99A999Gg&& 7 77@@((v6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7s   &A++A/	2A/	c                    g d}t          ddd          D ]t\  }}}|D ]k}|                    |||          }|                     |          5  t          |          }|                     |d           d d d            n# 1 swxY w Y   lud S )N)zC({}, {}, {})zC({}, {}, c={})zC({}, b={}, c={})zC(a={}, b={}, c={})rW  rX  rY  rv   )r   rD  r^   r   rT   )r0   formsr   r   r   formr   r1   s           r   test_static_swaps_match_classz+TestTranforms.test_static_swaps_match_classp  s    
 
 
 tT400 	; 	;GAq! ; ;++aA..\\'** ; ;;GDDD,,T6:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;;	; 	;s   &A>>BBc                 X   h d}g d}t          ddd          D ]\  }}}|D ]}|                    |||          }|                     |          5  t          |          }||v r|                     |d           n|                     |d           d d d            n# 1 swxY w Y   d S )N>   *_, b, ca, *_, ca, b, *_)z
{}, {}, {}z{}, {}, *{}z{}, *{}, {}z*{}, {}, {}rW  rX  rY  rv   )r   rD  r^   r   rU   rT   )	r0   swapsr]  r   r   r   r^  r   r1   s	            r    test_static_swaps_match_sequencez.TestTranforms.test_static_swaps_match_sequence~  s   444KKKtT400 
	? 
	?GAq! 	? 	?++aA..\\'** ? ?;GDDD%'' --dF;;;;00v>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ?	?
	? 
	?s   ABB!$B!N)(__name__
__module____qualname__r5   rH   rV   rb   ro   rt   r{   r   r   r   r   r   r   r   unittestskipr   r   r   r   r   r   r   r   r   r   r  r  r  r8  rG  rN  rR  rU  r[  r_  re  r"   r   r   r   r   $   sS       D D D*	9 	9 	9	  	  	 
( 
( 
(  6
 
 
( ( ('" '" '"R( ( (  >+  +  + Z     .!( !( !(F   X] 9 : : : :  	 	 	!= != !=F  $  ( ( (,' ' '# # #    
 
 
J J JB B B.M M M*> > >>, , ,, , ,7 7 7; ; ;? ? ? ? ?r   r   c                   &    e Zd Zd Zd Zd Zd ZdS )TestBugletsc                     d }|                      t                    5   |             d d d            d S # 1 swxY w Y   d S )Nc                      ddh\  } }| |fS )Nr   r"   rI  s     r   r   z%TestBuglets.test_bug_11510.<locals>.f  s    q6DAqa4Kr   )assertRaisesrL  r   s     r   test_bug_11510zTestBuglets.test_bug_11510  s    	 	 	 z** 	 	ACCC	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   6::c                 f    t          d          D ] }	 t          # t          pt          $ r Y w xY wd S )Nr   )r   	Exception)r0   r<  s     r   test_bpo_42057zTestBuglets.test_bpo_42057  sP    r 	 	A)	   	 	s   ..c                 (    t          ddd           d S )Nzwhile True or spam: pass<test>r
   r_   rM  s    r   test_bpo_45773_pop_jump_if_truez+TestBuglets.test_bpo_45773_pop_jump_if_true  s    *Hf=====r   c                 (    t          ddd           d S )Nzwhile True or not spam: passru  r
   rv  rM  s    r    test_bpo_45773_pop_jump_if_falsez,TestBuglets.test_bpo_45773_pop_jump_if_false  s    .&AAAAAr   N)rf  rg  rh  rp  rs  rw  ry  r"   r   r   rl  rl    sU            > > >B B B B Br   rl  __main__)r   	itertoolsr   r   r   ri  test.support.bytecode_helperr   r   r   r   TestCaserl  rf  mainr"   r   r   <module>r     s    



 + + + + + + + +   9 9 9 9 9 9# # #
 
 
g	? g	? g	? g	? g	?$ g	? g	? g	?TB B B B B(# B B B4 zHMOOOOO r   