
    ;e                     f    d dl Z dZ G d de j                  Zedk    r e j                     dS dS )    NGlobal variablec                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )DictComprehensionTestc                     ddddddddd	d
d
}d t          d          D             }|                     ||           ddddddddddd
}d t          d          D             }|                     ||           d S )N
                              
r                           	   c                     i | ]}||d z   	S r    .0ks     */usr/lib/python3.11/test/test_dictcomps.py
<dictcomp>z5DictComprehensionTest.test_basics.<locals>.<dictcomp>   s    ///!QV///    r   r   r   r   r   r   r   r   r   r   c                 D    i | ]}t          d           D ]}||k    ||S r   ranger   r    vs      r!   r"   z5DictComprehensionTest.test_basics.<locals>.<dictcomp>   s1    GGG1599GGaQ!Qr#   r&   assertEqualselfexpectedactuals      r!   test_basicsz!DictComprehensionTest.test_basics	   s    bRB2"b" "//U2YY///***Q1qQ1qQOOGGb		GGG*****r#   c                 (   d}d d d d d d d d d d d
}d t          d          D             }|                     ||           |                     |d           i ddddd	dd
dddddddddddddddddddddddddddi ddddddddd d!d"d!d#d!d$d!d%d!d&d!d'd!d(d)d*d)d+d)d,d)d-d)d.d)d)d)dddddddddd/}d0 t          d          D             }|                     |d           |                     ||           d S )1NzLocal Variabler   c                     i | ]}|d S Nr   r   s     r!   r"   z>DictComprehensionTest.test_scope_isolation.<locals>.<dictcomp>       ---a!T---r#   r   r   r   r   r   r      r         $   r   %   &   '   -   r   .   /   0   1   6   r   7   8   9   :   ;   ?   r   @   A   B   C   D   E   H   r   I   J   K   L   M   N   O   Q   R   S   T   U   V   W   X   Y   c                 F    i | ]}t          |d z  |dz            D ]}||S r   r   r%   )r   r(   r    s      r!   r"   z>DictComprehensionTest.test_scope_isolation.<locals>.<dictcomp>"   9    HHH15QB3G3GHHa!QHHHHr#   r)   )r,   r    r-   r.   s       r!   test_scope_isolationz*DictComprehensionTest.test_scope_isolation   s[   $4D$8 8--599---***,---7Aq 7"a 7Q 7A 7r1 7b! 7R 7B 77q7"$a7)+Q702A77917>@!7EG77 7q7"$a7)+Q702A77917>@!7EG7 7 q7 #%a7 *,Q7 13A7 8:17 ?A!7 FH7 	7 q	7 7 '(QA1!qaQA7 7 7 IHb		HHH,---*****r#   c                 8   d d d d d d d d d d d
}d t          d          D             }|                     ||           |                     t          d           i ddddd	dd
dddddddddddddddddddddddddddi ddddddddd d!d"d!d#d!d$d!d%d!d&d!d'd!d(d)d*d)d+d)d,d)d-d)d.d)d)d)dddddddddd/}d0 t          d          D             }|                     t          d           |                     ||           d S )1Nr   c                     i | ]}|d S r2   r   )r   gs     r!   r"   zJDictComprehensionTest.test_scope_isolation_from_global.<locals>.<dictcomp>)   r3   r#   r   r   r   r   r   r   r   r4   r   r5   r6   r7   r   r8   r9   r:   r;   r   r<   r=   r>   r?   r@   r   rA   rB   rC   rD   rE   rF   r   rG   rH   rI   rJ   rK   rL   rM   r   rN   rO   rP   rQ   rR   rS   c                 F    i | ]}t          |d z  |dz            D ]}||S r`   r%   )r   r(   re   s      r!   r"   zJDictComprehensionTest.test_scope_isolation_from_global.<locals>.<dictcomp>3   ra   r#   )r&   r*   re   r+   s      r!    test_scope_isolation_from_globalz6DictComprehensionTest.test_scope_isolation_from_global&   sV   $4D$8 8--599---***-...7Aq 7"a 7Q 7A 7r1 7b! 7R 7B 77q7"$a7)+Q702A77917>@!7EG77 7q7"$a7)+Q702A77917>@!7EG7 7 q7 #%a7 *,Q7 13A7 8:17 ?A!7 FH7 	7 q	7 7 '(QA1!qaQA7 7 7 IHb		HHH-...*****r#   c                 ~    ddddddddddd
}d t          d          D             }|                     ||           d S )Nr   r   c                     i | ]
}|t           S r   )re   r   s     r!   r"   z@DictComprehensionTest.test_global_visibility.<locals>.<dictcomp>=   s    ***1!Q***r#   r   r)   r+   s      r!   test_global_visibilityz,DictComprehensionTest.test_global_visibility7   se    (->(->(->(->(->	@ @
 +*b		********r#   c                     dddddddddddd
}fdt          d          D             }|                     ||           |                     d           d S )NzLocal variabler   c                     i | ]}|S r   r   r'   s     r!   r"   z?DictComprehensionTest.test_local_visibility.<locals>.<dictcomp>G   s    ***1!Q***r#   r   r)   )r,   r-   r.   r(   s      @r!   test_local_visibilityz+DictComprehensionTest.test_local_visibility@   s    ',<',<',<',<',<	> >
 +***b		******,-----r#   c                    |                      t          d          5  t          ddd           d d d            n# 1 swxY w Y   |                      t          d          5  t          ddd           d d d            d S # 1 swxY w Y   d S )Nzcannot assignz'{x: y for y, x in ((1, 2), (3, 4))} = 5z<test>execzillegal expressionz({x: y for y, x in ((1, 2), (3, 4))} += 5)assertRaisesRegexSyntaxErrorcompile)r,   s    r!   test_illegal_assignmentz-DictComprehensionTest.test_illegal_assignmentK   s   ##KAA 	 	=x  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ##K1EFF 	 	>  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   :>> A??BBc                     ddddd}g d}g fdfdt          d	d
          D             }|                     ||           |                     |           d S )NWold)Herw   rv   )
)keyry   )valueru   )r{   rz   )r|   rv   r{   rw   )r|   rr}   )r|   rw   )r{   rv   )r|   rx   c                 6                         | |f           |S r2   )append)posr|   actual_callss     r!   add_callz=DictComprehensionTest.test_evaluation_order.<locals>.add_callf   s     e---Lr#   c                 D    i | ]\  }} d |           d|          S )r{   r|   r   )r   r    r(   r   s      r!   r"   z?DictComprehensionTest.test_evaluation_order.<locals>.<dictcomp>j   sG     
 
 
1 HUA! 4 4
 
 
r#   HelloWorld)zipr*   )r,   r-   expected_callsr.   r   r   s       @@r!   test_evaluation_orderz+DictComprehensionTest.test_evaluation_orderT   s    	
 

 
 
 	 	 	 	 	
 
 
 
GW--
 
 

 	***~66666r#   c                 J   ddddd}d t          d          D             }|                     ||           ddd	d
d}d t          d          D             }|                     ||           ddd	d
d}d t          d          D             }|                     ||           d S )Nr   r   r   r   )r   r   r   r   c                 $    i | ]}|d z   }|||z  S r   r   )r   ijs      r!   r"   zQDictComprehensionTest.test_assignment_idiom_in_comprehensions.<locals>.<dictcomp>t   s&    :::QQqSq!QqS:::r#   r   r   r	      )r   r   r   r   c                 4    i | ]}|d z   }|d z   }||z   ||z  S r   r   r   r   r   r    s       r!   r"   zQDictComprehensionTest.test_assignment_idiom_in_comprehensions.<locals>.<dictcomp>w   s2    KKKqqsac!A#qsKKKr#   c                 4    i | ]}|d z   |dz   }}||z   ||z  S )r   r   r   r   s       r!   r"   zQDictComprehensionTest.test_assignment_idiom_in_comprehensions.<locals>.<dictcomp>z   s2    GGGqAaC1Q!!A#qsGGGr#   r)   r+   s      r!   'test_assignment_idiom_in_comprehensionsz=DictComprehensionTest.test_assignment_idiom_in_comprehensionsr   s    Q1,,::%((:::***Q2"--KKE!HHKKK***Q2"--GGE!HHGGG*****r#   c                     ddddd}|                      d g t          d          D             |           |                      d g t          d          R D             |           d S )Nr   r   r   r   )r   r   r   r   c                     i | ]}|||z  	S r   r   r   r   s     r!   r"   z>DictComprehensionTest.test_star_expression.<locals>.<dictcomp>   s    666Q!QqS666r#   c                     i | ]}|||z  	S r   r   r   s     r!   r"   z>DictComprehensionTest.test_star_expression.<locals>.<dictcomp>   s    777Q!QqS777r#   )r*   r&   )r,   r-   s     r!   test_star_expressionz*DictComprehensionTest.test_star_expression}   sy    Q1++66+E!HH+666AAA77,E!HH,,777BBBBBr#   N)__name__
__module____qualname__r/   rb   rg   rj   rm   rs   r   r   r   r   r#   r!   r   r      s        + + ++ + +&+ + +"+ + +	. 	. 	.  7 7 7<	+ 	+ 	+C C C C Cr#   r   __main__)unittestre   TestCaser   r   mainr   r#   r!   <module>r      sy     yC yC yC yC yCH- yC yC yCx zHMOOOOO r#   