a
    ze|!                     @   s   d dl Z d dlmZ d dlZejZG dd dZG dd deZG dd de j	Z
G d	d
 d
ZG dd dee j	ZG dd dZG dd dee j	ZG dd dee j	ZG dd dee j	ZG dd dee j	ZG dd dee j	ZG dd de j	ZG dd de j	Zedkre   dS )    N)supportc                   @   s   e Zd Zdd ZdS )newstylec                 C   s   | j S N)indself r   %/usr/lib/python3.9/test/test_index.py	__index__   s    znewstyle.__index__N__name__
__module____qualname__r
   r   r   r   r	   r      s   r   c                   @   s   e Zd Zdd ZdS )TrapIntc                 C   s   t | S r   )intr   r   r   r	   r
      s    zTrapInt.__index__Nr   r   r   r   r	   r   
   s   r   c                   @   sL   e Z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
dS )BaseTestCasec                 C   s   t  | _t  | _d S r   )r   onr   r   r   r	   setUp   s    zBaseTestCase.setUpc                 C   s<   d| j _d| j_| t| j d | t| jd d S N   )r   r   r   assertEqualoperatorindexr   r   r   r	   
test_basic   s    zBaseTestCase.test_basicc                 C   s   d| j _d| j_t| j | j | j }tddd}| || j |d t| j| j| j}tddd}| || j|d d S )N   r   )r   r   r   slicer   indices)r   ZslcZ	check_slcr   r   r	   
test_slice   s    zBaseTestCase.test_slicec                 C   sz   d| j _d| j_| d d | d  d | | j  d | | j d | d d | d d	 d S )
N            iTr   Fr   )r   r   r   r   r
   r   r   r   r	   test_wrappers#   s    zBaseTestCase.test_wrappersc                 C   sL   t td}| |tdtd |dd  | tt dd d S )N
   r!   r   )r   r   r   )listranger   r   r   r   )r   rr   r   r	   test_subclasses-   s    $zBaseTestCase.test_subclassesc                 C   sd   d| j _d| j_| ttj| j  | ttj| j | tt| j jd | tt| jjd d S )Ndumbbadr   )	r   r   r   assertRaises	TypeErrorr   r   r   r   r   r   r   r	   
test_error2   s    zBaseTestCase.test_errorc                 C   sV   G dd dt }|d}| }t|}| |d | |d | t|t  d S )Nc                   @   s   e Zd Zdd ZdS )z8BaseTestCase.test_int_subclass_with_index.<locals>.MyIntc                 S   s   t t| d S )Nr   )r   strr   r   r   r	   r
   >   s    zBBaseTestCase.test_int_subclass_with_index.<locals>.MyInt.__index__Nr   r   r   r   r	   MyInt=   s   r0   r#      )r   r
   r   r   r   assertIstype)r   r0   Zmy_intZdirect_indexZoperator_indexr   r   r	   test_int_subclass_with_index:   s    
z)BaseTestCase.test_int_subclass_with_indexc                 C   s   G dd d}G dd dt }| }| t t|}W d    n1 sN0    Y  | |d | }t|}| |d d S )Nc                   @   s   e Zd Zdd ZdS )z<BaseTestCase.test_index_returns_int_subclass.<locals>.BadIntc                 S   s   dS NTr   r   r   r   r	   r
   L   s    zFBaseTestCase.test_index_returns_int_subclass.<locals>.BadInt.__index__Nr   r   r   r   r	   BadIntK   s   r6   c                   @   s   e Zd Zdd ZdS )z=BaseTestCase.test_index_returns_int_subclass.<locals>.BadInt2c                 S   s   dS r5   r   r   r   r   r	   r
   P   s    zGBaseTestCase.test_index_returns_int_subclass.<locals>.BadInt2.__index__Nr   r   r   r   r	   BadInt2O   s   r7   r   r   )r   ZassertWarnsDeprecationWarningr   r   r   )r   r6   r7   Zbad_intr   r   r   r	   test_index_returns_int_subclassJ   s    (
z,BaseTestCase.test_index_returns_int_subclassN)r   r   r   r   r   r   r$   r)   r.   r4   r9   r   r   r   r	   r      s   

r   c                   @   sL   e Z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
dS )SeqTestCasec                 C   s$   t  | _t  | _t  | _t  | _d S r   )r   r   r   o2n2r   r   r   r	   r   `   s    zSeqTestCase.setUpc                 C   sH   d| j _d| j_| | j| j | jd  | | j| j  | jd  d S r   r   r   r   r   seqr   r   r   r	   
test_indexf   s    zSeqTestCase.test_indexc                 C   sl   d| j _d| j_d| j_d| j_| | j| j | j | jdd  | | j| j| j | jdd  d S )Nr      r   r    )r   r   r;   r   r<   r   r>   r   r   r   r	   r   l   s    $zSeqTestCase.test_slicec                 C   s:  t | j}t|d | j_|d | j_| | j| jd  | jdd  | | jd | j | j | | j| jd  | jdd  | | jd | j | j | d | j_t|d  | j_| | j| jd  | j | | jd | j | jdd  | | j| jd  | j | | jd | j | jdd  d S )Ng      ?r   r   )	lenr>   r   r   r   r   r   r;   r<   )r   Zseqlenr   r   r	   test_slice_bug7532t   s    
"""zSeqTestCase.test_slice_bug7532c                 C   s|   d| j _d| j_| | j| j  | jd  | | j| j | jd  | | j | j | jd  | | j| j | jd  d S )Nr@   r   r=   r   r   r   r	   test_repeat   s    zSeqTestCase.test_repeatc                 C   s   d| j _d| j_| | j| j | jd  | | j| j | jd  | | j| j | jd  | | j| j| jd  | | j| j| jd  | | j| j| jd  d S )Nr    r!   )r   r   r   r   r>   __getitem____mul____rmul__r   r   r   r	   r$      s    zSeqTestCase.test_wrappersc                 C   s   |  | jt  | jd  d S )Nr   )r   r>   r   r   r   r   r	   r)      s    zSeqTestCase.test_subclassesc                 C   sl   d| j _d| j_dd }| t|| j |  | t|| j|  dd }| t|| j |  | t|| j|  d S )Nr*   r+   c                 S   s
   |j |  S r   r>   xobjr   r   r	   <lambda>       z(SeqTestCase.test_error.<locals>.<lambda>c                 S   s   |j | d  S r   rG   rH   r   r   r	   rK      rL   )r   r   r   r,   r-   )r   ZindexobjZsliceobjr   r   r	   r.      s    zSeqTestCase.test_errorN)r   r   r   r   r?   r   rB   rC   r$   r)   r.   r   r   r   r	   r:   ]   s   
r:   c                   @   s$   e Zd Zg dZdd Zdd ZdS )ListTestCaser   r%         (   2   c                 C   s   d| j _d| j_td}|| j = || j= d|| j < d|| j< | |td g d}|| jd | |g d	 || j | |g d
 d S )Nr   r   zab!cdefghi!jXYZ
abYdefghXj)r!   r"   r#   r1   	   r%      here)r!   r"   rW   r1   rU   r%   rV   )r!   r"   r1   rU   r%   rV   )r   r   r   r&   r   __setitem____delitem__)r   lstr   r   r	   test_setdelitem   s    

zListTestCase.test_setdelitemc                 C   s   d| j _d| j_ddg}|| j 9 }| |g d || j9 }| |g dd  g d}|| j}| || | |g dd  d S )Nr   r@   r"   r    )r"   r    r"   r    )r!   r"   r#   r1   rU   rV   )r   r   r   r   __imul__r2   )r   rZ   l2r   r   r	   test_inplace_repeat   s    

z ListTestCase.test_inplace_repeatN)r   r   r   r>   r[   r^   r   r   r   r	   rM      s   rM   c                   @   s@   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZeZdd Z	dS )NewSeqc                 C   s   t || _d S r   )r&   _list)r   iterabler   r   r	   __init__   s    zNewSeq.__init__c                 C   s
   t | jS r   )reprr`   r   r   r   r	   __repr__   s    zNewSeq.__repr__c                 C   s
   | j |kS r   r`   )r   otherr   r   r	   __eq__   s    zNewSeq.__eq__c                 C   s
   t | jS r   )rA   r`   r   r   r   r	   __len__   s    zNewSeq.__len__c                 C   s   |  | j| S r   )	__class__r`   r   r   r   r   r	   rE      s    zNewSeq.__mul__c                 C   s
   | j | S r   re   )r   r   r   r   r	   rD      s    zNewSeq.__getitem__N)
r   r   r   rb   rd   rg   rh   rE   rF   rD   r   r   r   r	   r_      s   r_   c                   @   s   e Zd ZdZdS )TupleTestCaserN   Nr   r   r   r>   r   r   r   r	   rk      s   rk   c                   @   s   e Zd ZedZdS )ByteArrayTestCase   this is a testN)r   r   r   	bytearrayr>   r   r   r   r	   rm      s   rm   c                   @   s   e Zd ZdZdS )BytesTestCasern   Nrl   r   r   r   r	   rp      s   rp   c                   @   s   e Zd ZdZdS )StringTestCasezthis is a testNrl   r   r   r   r	   rq      s   rq   c                   @   s   e Zd ZedZdS )NewSeqTestCaserN   N)r   r   r   r_   r>   r   r   r   r	   rr      s   rr   c                   @   s   e Zd Zdd ZdS )RangeTestCasec                 C   s>   t  }d|_| tdd| d | tdd|d d S )Nr!   r   rO   r"   )r   r   r   r'   rD   rj   r   r   r	   
test_range   s    zRangeTestCase.test_rangeN)r   r   r   rt   r   r   r   r	   rs      s   rs   c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
OverflowTestCasec                 C   s   dd | _ | j  | _d S )Nr   d   )posnegr   r   r   r	   r      s    
zOverflowTestCase.setUpc                 C   s,   |  | j | j |  | j | j d S r   )r   rw   r
   rx   r   r   r   r	   test_large_longs   s    z!OverflowTestCase.test_large_longsc                 C   s   G dd d}| }|  || j | j |  || j | j |  || j| j tdtdf |  || j| jd tdtdf d S )Nc                   @   s   e Zd Zdd Zdd ZdS )z.OverflowTestCase.test_getitem.<locals>.GetItemc                 S   s   d S r   r   r   r   r   r	   rh     s    z6OverflowTestCase.test_getitem.<locals>.GetItem.__len__c                 S   s   |S r   r   )r   keyr   r   r	   rD     s    z:OverflowTestCase.test_getitem.<locals>.GetItem.__getitem__N)r   r   r   rh   rD   r   r   r   r	   GetItem   s   r{   r   r   )r   rw   rx   r   maxsize)r   r{   rI   r   r   r	   test_getitem   s    zOverflowTestCase.test_getitemc                    s,     t fdd   t fdd d S )Nc                      s
   d j  S Na)rw   r   r   r   r	   rK     rL   z7OverflowTestCase.test_sequence_repeat.<locals>.<lambda>c                      s
   d j  S r~   )rx   r   r   r   r	   rK     rL   )r,   OverflowErrorr   r   r   r	   test_sequence_repeat  s    z%OverflowTestCase.test_sequence_repeatN)r   r   r   r   ry   r}   r   r   r   r   r	   ru      s   ru   __main__)Zunittesttestr   r   ZMAX_Py_ssize_tr|   r   r   r   ZTestCaser   r:   rM   r_   rk   rm   rp   rq   rr   rs   ru   r   mainr   r   r   r	   <module>   s$   OF"	
