o
    g&                     @   sZ   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r+e
  dS 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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rc| 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   D/Users/admin/.pyenv/versions/3.10.0/lib/python3.10/test/test_list.py	<genexpr>   s    z&ListTest.test_basic.<locals>.<genexpr>
   )r   r         	   ir   c                 s   s    | ]}| V  qd S Nr   )r   yr   r   r   r   *   s    )	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    d S 1 sw   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   s    z#ListTest.test_overflow.<locals>.mulc                 S   s   | |9 } d S r   r   r1   r   r   r   imulC       z$ListTest.test_overflow.<locals>.imul)intr   r   r-   r   r   OverflowError)r!   lstnr3   r4   r   r   r   test_overflow?   s   zListTest.test_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   checkI   s
   
z'ListTest.test_repr_large.<locals>.checkr   i@B r   )r!   rA   r   r$   r   test_repr_largeG   s   zListTest.test_repr_largec           	      C   s  |  g d}g d}ttjd D ]}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
| qut||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_pickleQ   s8   
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| qt||f|}t|\}}||d d < | t|t| | t	|g  | tt| t||f|}t|\}}||d d < | t	|g  qd S )Nr.   rC   r   r   )rI   r   rJ   rK   reversedrM   rN   r   rO   r   r-   rP   r   rQ   rR   r   r   r   test_reversed_pickleu   s8   ""
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   r/   r   r   r   )r   r   r   )r!   r   r   r   r   test_step_overflow   s   zListTest.test_step_overflowc                 C   sP   G dd dt }| t d|ddg  W d    d S 1 s!w   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   r5   r`   )r   r   r   )r   r   r#   )r!   r`   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                          e Zd Z fddZdS )z9ListTest.test_equal_operator_modifying_operand.<locals>.Xc                           tS r   clearNotImplementedr!   otherlist2r   r   __eq__      z@ListTest.test_equal_operator_modifying_operand.<locals>.X.__eq__Nr]   r^   r_   rk   r   ri   r   r   X       rn   c                       rb   )z9ListTest.test_equal_operator_modifying_operand.<locals>.Yc                    rc   r   rd   rg   list1r   r   rk      rl   z@ListTest.test_equal_operator_modifying_operand.<locals>.Y.__eq__Nrm   r   rp   r   r   Y   ro   rr   c                       rb   )z9ListTest.test_equal_operator_modifying_operand.<locals>.Zc                    rc   r   rd   rg   list3r   r   rk      rl   z@ListTest.test_equal_operator_modifying_operand.<locals>.Z.__eq__Nrm   r   rs   r   r   Z   ro   ru   r   )r   ZassertFalse)r!   rn   rr   ru   Zlist4r   )rq   rj   rt   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 s"w   Y  G dd dt}|| g    || g |  t    W d    n1 sUw   Y  | | g d v  | | g |  v  d S )Nc                       rb   )z3ListTest.test_count_index_remove_crashes.<locals>.Xc                    rc   r   rd   rg   r8   r   r   rk      rl   z:ListTest.test_count_index_remove_crashes.<locals>.X.__eq__Nrm   r   rz   r   r   rn      ro   rn   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   )strrf   rg   r   r   r   rk      rl   z:ListTest.test_count_index_remove_crashes.<locals>.L.__eq__Nrm   r   r   r   r   r`      s    r`   r   )r   
ValueErrorindexr   countremove)r!   rn   r`   r   rz   r   test_count_index_remove_crashes   s    
z(ListTest.test_count_index_remove_crashes)r]   r^   r_   r   rI   r"   r%   r(   r+   r,   r:   rB   rX   r[   r\   ra   rv   r   ry   r   __classcell__r   r   r)   r   r      s"    #
$$
r   __main__)r   testr   Ztest.supportr   rJ   ZunittestZ
CommonTestr   r]   mainr   r   r   r   <module>   s     b