
    daf#                         d dl Z d dlmZ d dlmZ d dlZd dlZ G d dej                        Ze	dk(  r ej                          yy)    N)
list_tests)cpython_onlyc                        e Zd ZeZd Zd Zd Z fdZd Z	 fdZ
d Zd Zd	 Zd
 Zd Zd Zd Zd Zed        Zd Z xZS )ListTestc                    | j                  t        g       g        g d}t        |      }| j                  ||       | j                  ||u       | j                  t        d      g        | j                  t        d      g d       | j                  t        d      g        | j                  t        d      g d       | j                  t        d t        d      D              g d       t        j
                  d	k(  r5| j                  t        t        t        t        j
                  d
z               g }|j                  d |D               | j                  |g        y )N)r              spam)spamc              3   ,   K   | ]  }|d z  s	|  yw)r	   Nr   ).0xs     )/root/Python-3.12.4/Lib/test/test_list.py	<genexpr>z&ListTest.test_basic.<locals>.<genexpr>   s     <Aa!ea<s   

   )r   r
         	   ir	   c              3   "   K   | ]  }|  	 y wNr   )r   ys     r   r   z&ListTest.test_basic.<locals>.<genexpr>*   s     !s   )	assertEquallist
assertTruerangesysmaxsizeassertRaisesMemoryErrorextend)selfl0_3l0_3_bisr   s       r   
test_basiczListTest.test_basic
   s   b2&:x(H,-b2&l+\:b2&f';<<r<<(	* ;;*$ k4s{{a7G1HI 	QB    c                 r    | j                  t        d      5  t        g        d d d        y # 1 sw Y   y xY w)Nzkeyword argumentsequence)assertRaisesRegex	TypeErrorr   r'   s    r   test_keyword_argszListTest.test_keyword_args-   s0    ##I/AB 	"	 	 	s   -6c                     G d dt               } |ddg      }| j                  t        |      |       | j                  t        |      ddg       | j	                  t
              5   |d       d d d         G d dt               } |ddgd	
      }| j                  t        |      |       | j                  t        |      ddg       | j                  |j                  d	        G d dt               } |ddgd	
      }| j                  t        |      |       | j                  t        |      ddg       | j                  |j                  d	       y # 1 sw Y   xY w)Nc                       e Zd Zy)4ListTest.test_keywords_in_subclass.<locals>.subclassN__name__
__module____qualname__r   r+   r   subclassr5   2   s    r+   r:   r   r	   r   r-   c                         e Zd Zd fd	Z xZS )>ListTest.test_keywords_in_subclass.<locals>.subclass_with_initc                 2    t         |   |       || _        y r   )super__init__newarg)r'   seqr@   	__class__s      r   r?   zGListTest.test_keywords_in_subclass.<locals>.subclass_with_init.__init__;   s     %$r+   r   )r7   r8   r9   r?   __classcell__rB   s   @r   subclass_with_initr<   :   s    % %r+   rE   r
   )r@   c                         e Zd Zd fd	Z xZS )=ListTest.test_keywords_in_subclass.<locals>.subclass_with_newc                 6    t         |   | |      }||_        |S r   )r>   __new__r@   )clsrA   r@   r'   rB   s       r   rI   zEListTest.test_keywords_in_subclass.<locals>.subclass_with_new.__new__D   s    wsC0$r+   r   )r7   r8   r9   rI   rC   rD   s   @r   subclass_with_newrG   C   s     r+   rK   )r   assertIstyper   r$   r0   r@   )r'   r:   urE   rK   s        r   test_keywords_in_subclassz"ListTest.test_keywords_in_subclass1   s+   	t 	aVd1gx(a1a&)y) 	"b!	"	% 	% 1va0d1g12a1a&)1%	 	
 q!fQ/d1g01a1a&)1%)	" 	"s   '
EE!c                 j    t         |           | j                  g         | j                  dg       y )N*   )r>   
test_truthr    r'   rB   s    r   rR   zListTest.test_truthM   s*    Br+   c                 *    | j                  g g u       y r   )r    r1   s    r   test_identityzListTest.test_identityR   s    "%r+   c                     t         |           | j                  t        g       d       | j                  t        dg      d       | j                  t        g d      d       y )Nr   r   )r   r   r	   r
   )r>   test_lenr   lenrS   s    r   rW   zListTest.test_lenU   sL    R!$aS1%Y+r+   c                     g d}t        t        j                  dz  dz   t        |      z        }d }d }| j	                  t
        t        f|||       | j	                  t
        t        f|||       y )N   r      r   r	   c                     | |z  S r   r   r   bs     r   mulz#ListTest.test_overflow.<locals>.mul^   s
    a!e|r+   c                     | |z  } y r   r   r^   s     r   imulz$ListTest.test_overflow.<locals>.imul_   s
    Qr+   )intr"   r#   rX   r$   r%   OverflowError)r'   lstnr`   rb   s        r   test_overflowzListTest.test_overflow[   s^    QqSX-.#;6S!D;6c1Er+   c                 D   dgdz  }|dd = | j                  t        |      d       t        j                  }| j	                  t
        t        f      5  ||z   d d d        | j	                  t
        t        f      5  ||z  }d d d        y # 1 sw Y   3xY w# 1 sw Y   y xY w)Nr   A   r   )r   rX   r"   r#   r$   r%   rd   )r'   re   sizes      r   test_list_resize_overflowz"ListTest.test_list_resize_overflowc   s     cBhGS1%{{];< 	$J	];< 	4KC	 		 		 	s   B
;B
BBc                 0      fd} |d        |d       y )Nc                 ~    dg| z  }t        |      }j                  |ddj                  dg| z        z   dz          y )Nr   [z, 0])reprr   join)rf   lr   r'   s      r   checkz'ListTest.test_repr_large.<locals>.checkr   sC    aAQAQdii	**S02r+   r   i@B r   )r'   rt   s   ` r   test_repr_largezListTest.test_repr_largep   s    	2
 	b	gr+   c                    | j                  g d      }g d}t        t        j                  dz         D ]  }t	        |      }t        j
                  ||f|      }t        j                  |      \  }}||d d  | j                  t        |      t        |             | j                  t        |      |       t        |       t        j
                  ||f|      }t        j                  |      \  }}||d d  | j                  t        |      t        |             | j                  t        |      |dd         t        dt        |            D ]  }t        |        t        j
                  ||f|      }t        j                  |      \  }}||d d  | j                  t        |      t        |             | j                  t        |      |t        |      d         | j                  t        t        |       t        j
                  ||f|      }t        j                  |      \  }}||d d  | j                  t        |      g         y )NrZ   r                  r   )	type2testr!   pickleHIGHEST_PROTOCOLiterdumpsloadsr   rM   r   nextrX   r$   StopIteration	r'   origdataprotoitorigditr   is	            r   test_iterator_picklezListTest.test_iterator_picklez   s   ~~l+'622Q67 	+E$ZFfd^U3ALLOEBAaDT"XtF|4T"Xt, Lfd^U3ALLOEBAaDT"XtF|4T"XtABx0 1c$i( Vfd^U3ALLOEBAaDT"XtF|4T"XtCIJ'78 mT6:fd^U3ALLOEBAaDT"Xr*?	+r+   c                    | j                  g d      }g d}t        t        j                  dz         D ])  }t	        |      }t        j
                  ||f|      }t        j                  |      \  }}||d d  | j                  t        |      t        |             | j                  t        |      |t        |      dz
  d d          t        |       t        j
                  ||f|      }t        j                  |      \  }}||d d  | j                  t        |      t        |             | j                  t        |      |t        |      dz
  d d          t        dt        |            D ]  }t        |        t        j
                  ||f|      }t        j                  |      \  }}||d d  | j                  t        |      t        |             | j                  t        |      g        | j                  t        t        |       t        j
                  ||f|      }t        j                  |      \  }}||d d  | j                  t        |      g        , y )NrZ   rw   r   r	   )r}   r!   r~   r   reversedr   r   r   rM   r   rX   r   r$   r   r   s	            r   test_reversed_picklezListTest.test_reversed_pickle   s   ~~l+'622Q67 	+Ed^Ffd^U3ALLOEBAaDT"XtF|4T"XtCIaKOO'<= Lfd^U3ALLOEBAaDT"XtF|4T"XtCIaKOO'<= 1c$i( Vfd^U3ALLOEBAaDT"XtF|4T"Xr* mT6:fd^U3ALLOEBAaDT"Xr*?	+r+   c                     g d}dg|dd t         j                  <   | j                  |dd t         j                     dg       y )N)r   r   r	   r
   r[   r   r   r
   )r"   r#   r   )r'   r   s     r   test_step_overflowzListTest.test_step_overflow   s>    C!.S[[.1>ckk>*QC0r+   c                      G d dt               }| j                  t              5  d |ddg      z    d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zy)*ListTest.test_no_comdat_folding.<locals>.LNr6   r   r+   r   Lr      s    r+   r   )r
   r   r	   )r   r$   r0   )r'   r   s     r   test_no_comdat_foldingzListTest.test_no_comdat_folding   s>     	y) 	1aU8O	 	 	s	   <Ac                      G fdd      } G fdd      } G fdd      } |       g |       g| j                  k(          |       gdg}| j                  |k(         y )Nc                       e Zd Z fdZy)9ListTest.test_equal_operator_modifying_operand.<locals>.Xc                 0    j                          t        S r   clearNotImplemented)r'   otherlist2s     r   __eq__z@ListTest.test_equal_operator_modifying_operand.<locals>.X.__eq__       %%r+   Nr7   r8   r9   r   )r   s   r   Xr          &r+   r   c                       e Zd Z fdZy)9ListTest.test_equal_operator_modifying_operand.<locals>.Yc                 0    j                          t        S r   r   )r'   r   list1s     r   r   z@ListTest.test_equal_operator_modifying_operand.<locals>.Y.__eq__   r   r+   Nr   )r   s   r   Yr      r   r+   r   c                       e Zd Z fdZy)9ListTest.test_equal_operator_modifying_operand.<locals>.Zc                 0    j                          t        S r   r   )r'   r   list3s     r   r   z@ListTest.test_equal_operator_modifying_operand.<locals>.Z.__eq__   r   r+   Nr   )r   s   r   Zr      r   r+   r   r   )r    assertFalse)r'   r   r   r   list4r   r   r   s        @@@r   %test_equal_operator_modifying_operandz.ListTest.test_equal_operator_modifying_operand   sg    	& 	&
	& 	&
	& 	&
 '%(r+   c           
         dgdz  }t        j                  |      }| j                  |t        j                  t        dgdz                     | j                  |t        j                  t        t	        d                         y )Nr   r   )r"   	getsizeofr   r   r!   )r'   iterable	iter_sizes      r   test_preallocationzListTest.test_preallocation   s_    38MM(+	CMM$sRx.$ABCMM$uRy/$BCr+   c                     G fdd      } |       g| j                  t              5  j                         d d d         G d dt              } | |       g      j	                          | |       g      | j                  t              5  j                         d d d         |        |       gdv   |        |       g |       v  y # 1 sw Y   xY w# 1 sw Y   ?xY w)Nc                       e Zd Z fdZy)3ListTest.test_count_index_remove_crashes.<locals>.Xc                 0    j                          t        S r   r   )r'   r   re   s     r   r   z:ListTest.test_count_index_remove_crashes.<locals>.X.__eq__   s    		%%r+   Nr   )re   s   r   r   r      r   r+   r   c                       e Zd Zd Zy)3ListTest.test_count_index_remove_crashes.<locals>.Lc                 $    t        |       t        S r   )strr   )r'   r   s     r   r   z:ListTest.test_count_index_remove_crashes.<locals>.L.__eq__   s    E
%%r+   Nr   r   r+   r   r   r      s    &r+   r   r
   )r$   
ValueErrorindexr   countremove)r'   r   r   re   s      @r   test_count_index_remove_crashesz(ListTest.test_count_index_remove_crashes   s    	& 	&
 sez* 	IIcN		& 	&
 h		#hz* 	JJsO	
 sACj	SsACj	s
)	 		 	s   CC&C#&C/)r7   r8   r9   r   r}   r*   r2   rO   rR   rU   rW   rg   rk   ru   r   r   r   r   r   r   r   r   rC   rD   s   @r   r   r      sm    I! F&8
&,F"+H"+H1
)2 D Dr+   r   __main__)r"   testr   test.supportr   r~   unittest
CommonTestr   r7   mainr   r+   r   <module>r      sC    
  %  Gz$$ GT zHMMO r+   