B
    u9a4  ã               @   sJ   d dl Z d dlmZ d dlZd dlZG dd„ dejƒZedkrFe ¡  dS )é    N)Ú
list_testsc                   sl   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‡  ZS )ÚListTestc             C   s   |   tg ƒg ¡ ddddg}t|ƒ}|   ||¡ |  ||k	¡ |   tdƒg ¡ |   tdƒddddg¡ |   tdƒg ¡ |   tdƒd	d
ddg¡ |   tdd„ tdƒD ƒƒdddddg¡ tjdkrØ|  ttttjd ƒ¡ g }| dd„ |D ƒ¡ |   |g ¡ d S )Nr   é   é   é   © )r   r   r   r   Ú ZspamÚsÚpÚaÚmc             s   s   | ]}|d  r|V  qdS )r   Nr   )Ú.0Úxr   r   ú/usr/lib/python3.7/test_list.pyú	<genexpr>   s    z&ListTest.test_basic.<locals>.<genexpr>é
   é   é   é	   iÿÿÿ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 Q R X 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%   0   s    
zListTest.test_truthc             C   s   |   g g k	¡ d S )N)r   )r   r   r   r   Útest_identity5   s    zListTest.test_identityc                sF   t ƒ  ¡  |  tg ƒd¡ |  tdgƒd¡ |  tdddgƒd¡ d S )Nr   r   r   r   )r$   Útest_lenr   Úlen)r   )r&   r   r   r(   8   s    
zListTest.test_lenc             C   sb   ddddg}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 )Nr   )r   Úbr   r   r   ÚmulA   ó    z#ListTest.test_overflow.<locals>.mulc             S   s   | |9 } d S )Nr   )r   r,   r   r   r   ÚimulB   r.   z$ListTest.test_overflow.<locals>.imul)Úintr   r   r)   r   r   ÚOverflowError)r   ZlstÚnr-   r/   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)r2   Úlr	   )r   r   r   ÚcheckH   s    
z'ListTest.test_repr_large.<locals>.checkr   i@B r   )r   r:   r   )r   r   Útest_repr_largeF   s    zListTest.test_repr_largec       	      C   s¸  |   ddddg¡}ddddd	d
g}xŽttjd ƒD ]z}t|ƒ}t ||f|¡}t |¡\}}||d d …< |  t|ƒt|ƒ¡ |  t	|ƒ|¡ t
|ƒ t ||f|¡}t |¡\}}||d d …< |  t|ƒt|ƒ¡ |  t	|ƒ|dd … ¡ xtdt|ƒƒD ]}t
|ƒ qþW t ||f|¡}t |¡\}}||d d …< |  t|ƒt|ƒ¡ |  t	|ƒ|t|ƒd … ¡ |  tt
|¡ t ||f|¡}t |¡\}}||d d …< |  t	|ƒg ¡ q4W d S )Nr*   r   r+   r   r   é   é   é   é   é   r   )Ú	type2testr   ÚpickleÚHIGHEST_PROTOCOLÚiterÚdumpsÚloadsr   Útyper   Únextr)   r   ÚStopIteration)	r   ÚorigÚdataÚprotoÚitorigÚdÚitr   Úir   r   r   Útest_iterator_pickleP   s6    zListTest.test_iterator_picklec       	      C   sÊ  |   ddddg¡}ddddd	d
g}x 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… ¡ x tdt
|ƒƒD ]}t|ƒ qW t ||f|¡}t |¡\}}||d d …< |  t|ƒt|ƒ¡ |  t	|ƒg ¡ |  tt|¡ t ||f|¡}t |¡\}}||d d …< |  t	|ƒg ¡ q4W d S )Nr*   r   r+   r   r   r<   r=   r>   r?   r@   r   éÿÿÿÿr   )rA   r   rB   rC   ÚreversedrE   rF   r   rG   r   r)   rH   r   rI   )	r   rJ   rK   rL   rM   rN   rO   r   rP   r   r   r   Útest_reversed_picklet   s6    ""zListTest.test_reversed_picklec          	   C   s:   G dd„ dt ƒ}|  t¡ d|ddgƒ  W d Q R X 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œ   s    rX   )r   r   r   )r   r   r!   )r   rX   r   r   r   Útest_no_comdat_folding˜   s    zListTest.test_no_comdat_folding)rU   rV   rW   r   rA   r    r"   r%   r'   r(   r3   r;   rQ   rT   rY   Ú__classcell__r   r   )r&   r   r      s   #
$$r   Ú__main__)	r   Ztestr   rB   ZunittestZ
CommonTestr   rU   Úmainr   r   r   r   Ú<module>   s    