o
    GXîhô  ã                   @   sZ   d dl Z d dlmZ G dd„ dƒZG dd„ dƒZG dd„ de jƒZed	kr+e  ¡  dS dS )
é    N)Ú	ALWAYS_EQc                   @   s   e Zd Zdd„ ZdS )ÚEmptyc                 C   s   dS )Nz<Empty>© ©Úselfr   r   ú;/opt/python-3.10.19/usr/lib/python3.10/test/test_compare.pyÚ__repr__   s   zEmpty.__repr__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r      s    r   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚCmpc                 C   s
   || _ d S ©N©Úarg)r   r   r   r   r   Ú__init__	   ó   
zCmp.__init__c                 C   s
   d| j  S )Nz<Cmp %s>r   r   r   r   r   r      r   zCmp.__repr__c                 C   s
   | j |kS r   r   )r   Úotherr   r   r   Ú__eq__   r   z
Cmp.__eq__N)r	   r
   r   r   r   r   r   r   r   r   r      s    r   c                   @   sn   e Zd ZddddedƒgZdgddeƒ gZee Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )ÚComparisonTesté   g       @y       @        é   )é   Nc                 C   sR   | j D ]#}| j D ]}|| jv r|| jv s||u r|  ||¡ q|  ||¡ qqd S r   )Ú
candidatesÚset1ÚassertEqualZassertNotEqual)r   ÚaÚbr   r   r   Útest_comparisons   s   

üÿzComparisonTest.test_comparisonsc              	   C   sf   g }t dƒD ]}| t|ƒd tƒ ¡ q|D ]}|D ]}|  ||kt|ƒt|ƒkd||f ¡ qqd S )Né
   r   z
a=%r, b=%r)ÚrangeÚinsertÚlenr   r   Úid)r   ÚLÚir   r   r   r   r   Útest_id_comparisons   s   
ÿÿÿz"ComparisonTest.test_id_comparisonsc                 C   sL   t dƒ}t dƒ}t dƒ}|  ||kd¡ |  ||kd¡ |  ||kd¡ d S )Nr   r   TF)r   ÚassertIs)r   r   r   Úcr   r   r   Útest_ne_defaults_to_not_eq)   s   z)ComparisonTest.test_ne_defaults_to_not_eqc                    sH   g ‰ G ‡ fdd„dƒ}G ‡ fdd„dƒ}|ƒ |ƒ k |   ˆ ddg¡ dS )z;object.__ne__() should allow reflected __ne__() to be triedc                       ó   e Zd Z‡ fdd„ZdS )z2ComparisonTest.test_ne_high_priority.<locals>.Leftc                     ó   ˆ   d¡ tS )NúLeft.__eq__©ÚappendÚNotImplemented©Úargs©Zcallsr   r   r   6   ó   
z9ComparisonTest.test_ne_high_priority.<locals>.Left.__eq__N©r	   r
   r   r   r   r1   r   r   ÚLeft4   ó    r4   c                       ó$   e Zd Z‡ fdd„Z‡ fdd„ZdS )z3ComparisonTest.test_ne_high_priority.<locals>.Rightc                     r*   )NzRight.__eq__r,   r/   r1   r   r   r   :   r2   z:ComparisonTest.test_ne_high_priority.<locals>.Right.__eq__c                     r*   )NúRight.__ne__r,   r/   r1   r   r   Ú__ne__=   r2   z:ComparisonTest.test_ne_high_priority.<locals>.Right.__ne__N©r	   r
   r   r   r8   r   r1   r   r   ÚRight9   ó    r:   r+   r7   N©ZassertSequenceEqual)r   r4   r:   r   r1   r   Útest_ne_high_priority1   s
   z$ComparisonTest.test_ne_high_priorityc                    sJ   g ‰ G ‡ fdd„dƒ}G ‡ fdd„d|ƒ}|ƒ |ƒ k |   ˆ ddg¡ dS )z4object.__ne__() should not invoke reflected __eq__()c                       r)   )z1ComparisonTest.test_ne_low_priority.<locals>.Basec                     r*   )NúBase.__eq__r,   r/   r1   r   r   r   H   r2   z8ComparisonTest.test_ne_low_priority.<locals>.Base.__eq__Nr3   r   r1   r   r   ÚBaseF   r5   r?   c                       r6   )z4ComparisonTest.test_ne_low_priority.<locals>.Derivedc                     r*   )NzDerived.__eq__r,   r/   r1   r   r   r   L   r2   z;ComparisonTest.test_ne_low_priority.<locals>.Derived.__eq__c                     r*   )NúDerived.__ne__r,   r/   r1   r   r   r8   O   r2   z;ComparisonTest.test_ne_low_priority.<locals>.Derived.__ne__Nr9   r   r1   r   r   ÚDerivedK   r;   rA   r@   r>   Nr<   )r   r?   rA   r   r1   r   Útest_ne_low_priorityC   s
   z#ComparisonTest.test_ne_low_priorityc              	      sæ   ddd„ fddd„ fddd„ fdd	d„ fd
dd„ ff}|D ]S\}}ˆ   |¡B ‡ fdd„‰G ‡fdd„dƒ}|D ]\}}||krFt||ˆƒ q8|dkrWˆ  ||ƒ tƒ ƒd¡ n
ˆ  t||ƒ tƒ ¡ W d  ƒ n1 skw   Y  qdS )z8No default delegation between operations except __ne__()r   c                 S   s   | |kS r   r   ©r   r   r   r   r   Ú<lambda>X   ó    z6ComparisonTest.test_other_delegation.<locals>.<lambda>Ú__lt__c                 S   s   | |k S r   r   rC   r   r   r   rD   Y   rE   Ú__le__c                 S   s   | |kS r   r   rC   r   r   r   rD   Z   rE   Ú__gt__c                 S   s   | |kS r   r   rC   r   r   r   rD   [   rE   Ú__ge__c                 S   s   | |kS r   r   rC   r   r   r   rD   \   rE   c                     s   ˆ   d¡ d S )Nz!Unexpected operator method called)Zfailr/   r   r   r   Ú
unexpected`   s   z8ComparisonTest.test_other_delegation.<locals>.unexpectedc                       s   e Zd Z” ZdS )z/ComparisonTest.test_other_delegation.<locals>.CN)r	   r
   r   r8   r   )rJ   r   r   ÚCb   s    rK   FN)ZsubTestÚsetattrr&   ÚobjectZassertRaisesÚ	TypeError)r   ÚopsÚnameÚfuncrK   r   Ú_r   )r   rJ   r   Útest_other_delegationU   s*   




û€€õ€ÿz$ComparisonTest.test_other_delegationc                 C   sB   dd„ }|   |t¡ |   t|¡ tƒ }|   |t¡ |   t|¡ d S )Nc                   S   s   d S r   r   r   r   r   r   rD   m   s    z0ComparisonTest.test_issue_1393.<locals>.<lambda>)r   r   rM   )r   ÚxÚyr   r   r   Útest_issue_1393l   s   zComparisonTest.test_issue_1393)r	   r
   r   r   r   r   Zset2r   r   r%   r(   r=   rB   rS   rV   r   r   r   r   r      s    
r   Ú__main__)	ZunittestZtest.supportr   r   r   ZTestCaser   r	   Úmainr   r   r   r   Ú<module>   s    
cÿ