o
    HXîhb  ã                   @   sš  	 d dl Z d dlmZ d dlmZ d dlmZ dZG dd„ dƒZG dd	„ d	eƒ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	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e j
ƒZG d d!„ d!ee j
ƒZG d"d#„ d#eƒZG d$d%„ d%eƒZG d&d'„ d'eƒZG d(d)„ d)e j
ƒZed*krËe  ¡  dS dS )+é    N)Úrepeat)Údeque)Úlength_hinté
   c                   @   ó   e Zd Zdd„ ZdS )ÚTestInvariantWithoutMutationsc                 C   sh   | j }ttdtd ƒƒD ]}|  t|ƒ|¡ t|ƒ q|  t|ƒd¡ |  tt|¡ |  t|ƒd¡ d S ©Né   r   )	ÚitÚreversedÚrangeÚnÚassertEqualr   ÚnextÚassertRaisesÚStopIteration)Úselfr
   Úi© r   ú;/opt/python-3.10.19/usr/lib/python3.10/test/test_iterlen.pyÚtest_invariant6   s   
z,TestInvariantWithoutMutations.test_invariantN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   4   ó    r   c                   @   r   )ÚTestTemporarilyImmutablec                 C   s\   | j }|  t|ƒt¡ t|ƒ |  t|ƒtd ¡ |  ¡  |  tt|¡ |  t|ƒd¡ d S r   )r
   r   r   r   r   Úmutater   ÚRuntimeError)r   r
   r   r   r   Útest_immutable_during_iterationA   s   z8TestTemporarilyImmutable.test_immutable_during_iterationN)r   r   r   r   r   r   r   r   r   ?   r   r   c                   @   r   )Ú
TestRepeatc                 C   s   t d tƒ| _d S ©N)r   r   r
   ©r   r   r   r   ÚsetUpQ   s   zTestRepeat.setUpN©r   r   r   r"   r   r   r   r   r   O   r   r   c                   @   r   )Ú
TestXrangec                 C   ó   t ttƒƒ| _d S r    ©Úiterr   r   r
   r!   r   r   r   r"   V   ó   zTestXrange.setUpNr#   r   r   r   r   r$   T   r   r$   c                   @   r   )ÚTestXrangeCustomReversedc                 C   r%   r    ©r   r   r   r
   r!   r   r   r   r"   [   r(   zTestXrangeCustomReversed.setUpNr#   r   r   r   r   r)   Y   r   r)   c                   @   r   )Ú	TestTuplec                 C   s   t tttƒƒƒ| _d S r    )r'   Útupler   r   r
   r!   r   r   r   r"   `   s   zTestTuple.setUpNr#   r   r   r   r   r+   ^   r   r+   c                   @   r   )Ú	TestDequec                 C   ó"   t ttƒƒ}t|ƒ| _|j| _d S r    )r   r   r   r'   r
   Úpopr   ©r   Údr   r   r   r"   g   ó   
zTestDeque.setUpNr#   r   r   r   r   r-   e   r   r-   c                   @   r   )ÚTestDequeReversedc                 C   r.   r    )r   r   r   r   r
   r/   r   r0   r   r   r   r"   n   r2   zTestDequeReversed.setUpNr#   r   r   r   r   r3   l   r   r3   c                   @   r   )ÚTestDictKeysc                 C   s$   t  ttƒ¡}t|ƒ| _|j| _d S r    )ÚdictÚfromkeysr   r   r'   r
   Úpopitemr   r0   r   r   r   r"   u   s   
zTestDictKeys.setUpNr#   r   r   r   r   r4   s   r   r4   c                   @   r   )ÚTestDictItemsc                 C   ó(   t  ttƒ¡}t| ¡ ƒ| _|j| _d S r    )	r5   r6   r   r   r'   Úitemsr
   r7   r   r0   r   r   r   r"   |   ó   zTestDictItems.setUpNr#   r   r   r   r   r8   z   r   r8   c                   @   r   )ÚTestDictValuesc                 C   r9   r    )	r5   r6   r   r   r'   Úvaluesr
   r7   r   r0   r   r   r   r"   ƒ   r;   zTestDictValues.setUpNr#   r   r   r   r   r<      r   r<   c                   @   r   )ÚTestSetc                 C   r.   r    )Úsetr   r   r'   r
   r/   r   r0   r   r   r   r"   Š   r2   zTestSet.setUpNr#   r   r   r   r   r>   ˆ   r   r>   c                   @   ó   e Zd Zdd„ Zdd„ ZdS )ÚTestListc                 C   r%   r    r&   r!   r   r   r   r"   “   r(   zTestList.setUpc                 C   s¤   t ttƒƒ}t|ƒ}t|ƒ t|ƒ |  t|ƒtd ¡ | t¡ |  t|ƒtd ¡ g |dd …< |  t|ƒd¡ |  t |ƒg ¡ | tdƒ¡ |  t|ƒd¡ d S ©Né   r	   r   é   )	Úlistr   r   r'   r   r   r   ÚappendÚextend©r   r1   r
   r   r   r   Útest_mutation–   ó   
zTestList.test_mutationN©r   r   r   r"   rI   r   r   r   r   rA   ‘   ó    rA   c                   @   r@   )ÚTestListReversedc                 C   r%   r    r*   r!   r   r   r   r"   §   r(   zTestListReversed.setUpc                 C   s¤   t ttƒƒ}t|ƒ}t|ƒ t|ƒ |  t|ƒtd ¡ | t¡ |  t|ƒtd ¡ g |dd …< |  t|ƒd¡ |  t |ƒg ¡ | tdƒ¡ |  t|ƒd¡ d S rB   )	rE   r   r   r   r   r   r   rF   rG   rH   r   r   r   rI   ª   rJ   zTestListReversed.test_mutationNrK   r   r   r   r   rM   ¥   rL   rM   c                   @   r@   )ÚBadLenc                 C   ó   t tdƒƒS ©Nr   ©r'   r   r!   r   r   r   Ú__iter__¼   ó   zBadLen.__iter__c                 C   ó   t dƒ‚©NZhello©r   r!   r   r   r   Ú__len__¿   ó   zBadLen.__len__N)r   r   r   rR   rW   r   r   r   r   rN   »   ó    rN   c                   @   r@   )ÚBadLengthHintc                 C   rO   rP   rQ   r!   r   r   r   rR   Ä   rS   zBadLengthHint.__iter__c                 C   rT   rU   rV   r!   r   r   r   Ú__length_hint__Ç   rX   zBadLengthHint.__length_hint__N©r   r   r   rR   r[   r   r   r   r   rZ   Ã   rY   rZ   c                   @   r@   )ÚNoneLengthHintc                 C   rO   rP   rQ   r!   r   r   r   rR   Ì   rS   zNoneLengthHint.__iter__c                 C   s   t S r    )ÚNotImplementedr!   r   r   r   r[   Ï   s   zNoneLengthHint.__length_hint__Nr\   r   r   r   r   r]   Ë   rY   r]   c                   @   r@   )ÚTestLengthHintExceptionsc                 C   sx   |   tttƒ ¡ |   tttƒ ¡ |   tg jtƒ ¡ |   tg jtƒ ¡ ttdƒƒ}|   t|jtƒ ¡ |   t|jtƒ ¡ d S rP   )r   r   rE   rN   rZ   rG   Ú	bytearrayr   )r   Úbr   r   r   Útest_issue1242657Õ   s   z*TestLengthHintExceptions.test_issue1242657c                 C   s   |   ttƒ ƒttdƒƒ¡ d S rP   )r   rE   r]   r   r!   r   r   r   Útest_invalid_hintÞ   s   z*TestLengthHintExceptions.test_invalid_hintN)r   r   r   rb   rc   r   r   r   r   r_   Ó   s    	r_   Ú__main__)ZunittestÚ	itertoolsr   Úcollectionsr   Úoperatorr   r   r   r   ZTestCaser   r$   r)   r+   r-   r3   r4   r8   r<   r>   rA   rM   ÚobjectrN   rZ   r]   r_   r   Úmainr   r   r   r   Ú<module>   s6    +	ÿ