a
    ze                     @   sV   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 dejZe	dkrRe
  dS )    N)
list_tests)cpython_onlyc                       s   e Zd ZeZdd Zdd Z fddZdd Z fd	d
Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zedd Zdd Z  ZS )ListTestc                 C   s   |  tg g  g d}t|}|  || | ||u |  tdg  |  tdg d |  tdg  |  tdg d |  tdd tdD g d	 tjd
kr| ttttjd  g }|dd |D  |  |g  d S )N)r              Zspam)spamc                 s   s   | ]}|d  r|V  qdS )r   Nr   ).0xr   r   $/usr/lib/python3.9/test/test_list.py	<genexpr>       z&ListTest.test_basic.<locals>.<genexpr>
   )r   r         	   ir   c                 s   s   | ]}| V  qd S Nr   )r   yr   r   r   r   *   r   )	assertEquallist
assertTruerangesysmaxsizeassertRaisesMemoryErrorextend)selfZl0_3Zl0_3_bisr   r   r   r   
test_basic
   s"    
zListTest.test_basicc                 C   s:   |  td tg d W d    n1 s,0    Y  d S )Nzkeyword argument)Zsequence)ZassertRaisesRegex	TypeErrorr   r"   r   r   r   test_keyword_args-   s    zListTest.test_keyword_argsc                    s&   t    | g   | dg d S )N*   )super
test_truthr   r%   	__class__r   r   r)   1   s    
zListTest.test_truthc                 C   s   |  g g u d S r   )r   r%   r   r   r   test_identity6   s    zListTest.test_identityc                    sD   t    | tg d | tdgd | tg dd d S )Nr   r   )r   r   r   r   )r(   test_lenr   lenr%   r*   r   r   r-   9   s    
zListTest.test_lenc                 C   s^   g d}t tjd d t| }dd }dd }| ttf||| | ttf||| d S )N   r      r   r   c                 S   s   | | S r   r   r   br   r   r   mulB   r   z#ListTest.test_overflow.<locals>.mulc                 S   s   | |9 } d S r   r   r2   r   r   r   imulC   r   z$ListTest.test_overflow.<locals>.imul)intr   r   r.   r   r    OverflowError)r"   lstnr4   r5   r   r   r   test_overflow?   s    zListTest.test_overflowc                 C   s   dgd }|dd = |  t|d dtjd  d d }| ttf ||  W d    n1 sf0    Y  | ttf ||9 }W d    n1 s0    Y  d S )Nr   A   r   r      )r   r.   tuple__itemsize__r   r    r7   )r"   r8   sizer   r   r   test_list_resize_overflowG   s    

&z"ListTest.test_list_resize_overflowc                    s     fdd}|d |d d S )Nc                    s6   dg|  }t |} |dddg|   d  d S )Nr   [z, 0])reprr   join)r9   lr
   r%   r   r   checkV   s
    
z'ListTest.test_repr_large.<locals>.checkr   i@B r   )r"   rG   r   r%   r   test_repr_largeT   s    zListTest.test_repr_largec           	      C   s  |  g d}g d}ttjd D ]v}t|}t||f|}t|\}}||d d < | t|t| | t	|| t
| t||f|}t|\}}||d d < | t|t| | t	||dd   tdt|D ]}t
| qt||f|}t|\}}||d d < | t|t| | t	||t|d   | tt
| t||f|}t|\}}||d d < | t	|g  q$d S )Nr/   r                  r   )	type2testr   pickleHIGHEST_PROTOCOLiterdumpsloadsr   typer   nextr.   r   StopIteration	r"   ZorigdataprotoZitorigditr   ir   r   r   test_iterator_pickle^   s6    
zListTest.test_iterator_picklec           	      C   s  |  g d}g d}ttjd D ]}t|}t||f|}t|\}}||d d < | t|t| | t	||t
|d d d  t| t||f|}t|\}}||d d < | t|t| | t	||t
|d d d  tdt
|D ]}t| qt||f|}t|\}}||d d < | t|t| | t	|g  | tt| t||f|}t|\}}||d d < | t	|g  q$d S )Nr/   rI   r   r   )rO   r   rP   rQ   reversedrS   rT   r   rU   r   r.   rV   r   rW   rX   r   r   r   test_reversed_pickle   s6    ""zListTest.test_reversed_picklec                 C   s8   g d}dg|dd t j< | |dd t j dg d S )N)r   r   r   r   r0   r   r   r   )r   r   r   )r"   r   r   r   r   test_step_overflow   s    zListTest.test_step_overflowc                 C   sN   G dd dt }| t  d|ddg  W d    n1 s@0    Y  d S )Nc                   @   s   e Zd ZdS )z*ListTest.test_no_comdat_folding.<locals>.LN)__name__
__module____qualname__r   r   r   r   L   r   rf   )r   r   r   )r   r   r$   )r"   rf   r   r   r   test_no_comdat_folding   s    zListTest.test_no_comdat_foldingc                    st   G fddd}G  fddd}G fddd}| g | g|   k | gdg}| |k d S )Nc                       s   e Zd Z fddZdS )z9ListTest.test_equal_operator_modifying_operand.<locals>.Xc                    s       tS r   clearNotImplementedr"   otherlist2r   r   __eq__   s    z@ListTest.test_equal_operator_modifying_operand.<locals>.X.__eq__Nrc   rd   re   ro   r   rm   r   r   X   s   rq   c                       s   e Zd Z fddZdS )z9ListTest.test_equal_operator_modifying_operand.<locals>.Yc                    s       tS r   rh   rk   list1r   r   ro      s    z@ListTest.test_equal_operator_modifying_operand.<locals>.Y.__eq__Nrp   r   rr   r   r   Y   s   rt   c                       s   e Zd Z fddZdS )z9ListTest.test_equal_operator_modifying_operand.<locals>.Zc                    s       tS r   rh   rk   list3r   r   ro      s    z@ListTest.test_equal_operator_modifying_operand.<locals>.Z.__eq__Nrp   r   ru   r   r   Z   s   rw   r   )r   ZassertFalse)r"   rq   rt   rw   Zlist4r   )rs   rn   rv   r   %test_equal_operator_modifying_operand   s    z.ListTest.test_equal_operator_modifying_operandc                 C   sN   dgd }t |}| |t tdgd  | |t ttd d S )Nr   r   )r   	getsizeofr   r   r   )r"   iterableZ	iter_sizer   r   r   test_preallocation   s    

zListTest.test_preallocationc                    s   G  fddd}| g |  t    W d    n1 sD0    Y  G dd dt}|| g    || g |  t    W d    n1 s0    Y  | | g d v  | | g |  v  d S )Nc                       s   e Zd Z fddZdS )z3ListTest.test_count_index_remove_crashes.<locals>.Xc                    s       tS r   rh   rk   r8   r   r   ro      s    z:ListTest.test_count_index_remove_crashes.<locals>.X.__eq__Nrp   r   r|   r   r   rq      s   rq   c                   @   s   e Zd Zdd ZdS )z3ListTest.test_count_index_remove_crashes.<locals>.Lc                 S   s   t | tS r   )strrj   rk   r   r   r   ro      s    z:ListTest.test_count_index_remove_crashes.<locals>.L.__eq__Nrp   r   r   r   r   rf      s   rf   r   )r   
ValueErrorindexr   countremove)r"   rq   rf   r   r|   r   test_count_index_remove_crashes   s    (
(z(ListTest.test_count_index_remove_crashes)rc   rd   re   r   rO   r#   r&   r)   r,   r-   r:   r@   rH   r^   ra   rb   rg   rx   r   r{   r   __classcell__r   r   r*   r   r      s"   #
$$
r   __main__)r   testr   Ztest.supportr   rP   ZunittestZ
CommonTestr   rc   mainr   r   r   r   <module>   s    o