o
    HXh                     @   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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   8/opt/python-3.10.19/usr/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                 C   s   dgd }|dd = |  t|d dtjd  d d }| ttf ||  W d    n1 s3w   Y  | ttf ||9 }W d    d S 1 sOw   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 ]}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_pickle^   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.   rI   r   r   )rO   r   rP   rQ   reversedrS   rT   r   rU   r   r-   rV   r   rW   rX   r   r   r   test_reversed_pickle   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   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                          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rc   rd   re   rq   r   ro   r   r   X       rt   c                       rh   )z9ListTest.test_equal_operator_modifying_operand.<locals>.Yc                    ri   r   rj   rm   list1r   r   rq      rr   z@ListTest.test_equal_operator_modifying_operand.<locals>.Y.__eq__Nrs   r   rv   r   r   Y   ru   rx   c                       rh   )z9ListTest.test_equal_operator_modifying_operand.<locals>.Zc                    ri   r   rj   rm   list3r   r   rq      rr   z@ListTest.test_equal_operator_modifying_operand.<locals>.Z.__eq__Nrs   r   ry   r   r   Z   ru   r{   r   )r   ZassertFalse)r!   rt   rx   r{   Zlist4r   )rw   rp   rz   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                       rh   )z3ListTest.test_count_index_remove_crashes.<locals>.Xc                    ri   r   rj   rm   r8   r   r   rq      rr   z:ListTest.test_count_index_remove_crashes.<locals>.X.__eq__Nrs   r   r   r   r   rt      ru   rt   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   )strrl   rm   r   r   r   rq      rr   z:ListTest.test_count_index_remove_crashes.<locals>.L.__eq__Nrs   r   r   r   r   rf      s    rf   r   )r   
ValueErrorindexr   countremove)r!   rt   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   r|   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