
    <e/                        d dl Z d dlmZ d dlZ G d d          Z G d d          Zd ej        ej        fd ej        ej	        fd	 ej
        ej        fd
 ej        ej        fd ej        ej        fd ej        ej        fdZ G d de j                  Z G d de j                  Z G d de j                  Z G d de j                  Z G d de j                  Zedk    r e j                     dS dS )    N)supportc                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )Numberc                     || _         d S Nx)selfr	   s     (/usr/lib/python3.11/test/test_richcmp.py__init__zNumber.__init__
   s        c                     | j         |k     S r   r   r
   others     r   __lt__zNumber.__lt__       v~r   c                     | j         |k    S r   r   r   s     r   __le__zNumber.__le__       vr   c                     | j         |k    S r   r   r   s     r   __eq__zNumber.__eq__   r   r   c                     | j         |k    S r   r   r   s     r   __ne__zNumber.__ne__   r   r   c                     | j         |k    S r   r   r   s     r   __gt__zNumber.__gt__   r   r   c                     | j         |k    S r   r   r   s     r   __ge__zNumber.__ge__   r   r   c                 *    t          j        d          )Nz%Number.__cmp__() should not be calledr   
TestFailedr   s     r   __cmp__zNumber.__cmp__        !HIIIr   c                     d| j         dS )NzNumber()r   r
   s    r   __repr__zNumber.__repr__"   s     #vvv((r   N)__name__
__module____qualname__r   r   r   r   r   r   r   r!   r&    r   r   r   r      s                      J J J) ) ) ) )r   r   c                   f    e Zd Zd Zd Zd Zd ZdZd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZdS )Vectorc                     || _         d S r   data)r
   r/   s     r   r   zVector.__init__'   s    			r   c                 *    t          | j                  S r   )lenr/   r%   s    r   __len__zVector.__len__*   s    49~~r   c                     | j         |         S r   r.   )r
   is     r   __getitem__zVector.__getitem__-   s    y|r   c                     || j         |<   d S r   r.   )r
   r4   vs      r   __setitem__zVector.__setitem__0   s    	!r   Nc                      t          d          )Nz*Vectors cannot be used in Boolean contexts)	TypeErrorr%   s    r   __bool__zVector.__bool__5   s    DEEEr   c                 *    t          j        d          )Nz%Vector.__cmp__() should not be calledr   r   s     r   r!   zVector.__cmp__8   r"   r   c                     d| j         dS )NzVector(r$   r.   r%   s    r   r&   zVector.__repr__;   s     #yyy++r   c           	          t          d t          | j        |                     |                    D                       S )Nc                      g | ]\  }}||k     S r*   r*   .0abs      r   
<listcomp>z!Vector.__lt__.<locals>.<listcomp>?        LLLAq1uLLLr   r,   zipr/   _Vector__castr   s     r   r   zVector.__lt__>   7    LLTYE8J8J)K)KLLLMMMr   c           	          t          d t          | j        |                     |                    D                       S )Nc                      g | ]\  }}||k    S r*   r*   r@   s      r   rD   z!Vector.__le__.<locals>.<listcomp>B        MMM$!QqAvMMMr   rF   r   s     r   r   zVector.__le__A   7    MM#diU9K9K*L*LMMMNNNr   c           	          t          d t          | j        |                     |                    D                       S )Nc                      g | ]\  }}||k    S r*   r*   r@   s      r   rD   z!Vector.__eq__.<locals>.<listcomp>E   rL   r   rF   r   s     r   r   zVector.__eq__D   rM   r   c           	          t          d t          | j        |                     |                    D                       S )Nc                      g | ]\  }}||k    S r*   r*   r@   s      r   rD   z!Vector.__ne__.<locals>.<listcomp>H   rL   r   rF   r   s     r   r   zVector.__ne__G   rM   r   c           	          t          d t          | j        |                     |                    D                       S )Nc                      g | ]\  }}||k    S r*   r*   r@   s      r   rD   z!Vector.__gt__.<locals>.<listcomp>K   rE   r   rF   r   s     r   r   zVector.__gt__J   rI   r   c           	          t          d t          | j        |                     |                    D                       S )Nc                      g | ]\  }}||k    S r*   r*   r@   s      r   rD   z!Vector.__ge__.<locals>.<listcomp>N   rL   r   rF   r   s     r   r   zVector.__ge__M   rM   r   c                     t          |t                    r|j        }t          | j                  t          |          k    rt	          d          |S )Nz*Cannot compare vectors of different length)
isinstancer,   r/   r1   
ValueErrorr   s     r   __castzVector.__castP   sH    eV$$ 	JEty>>SZZ''IJJJr   )r'   r(   r)   r   r2   r5   r8   __hash__r;   r!   r&   r   r   r   r   r   r   rH   r*   r   r   r,   r,   %   s                HF F FJ J J, , ,N N NO O OO O OO O ON N NO O O    r   r,   c                     | |k     S r   r*   rB   rC   s     r   <lambda>r]   X   
    q!t r   c                     | |k    S r   r*   r\   s     r   r]   r]   Y   r^   r   c                     | |k    S r   r*   r\   s     r   r]   r]   Z   r^   r   c                     | |k    S r   r*   r\   s     r   r]   r]   [   r^   r   c                     | |k    S r   r*   r\   s     r   r]   r]   \   r^   r   c                     | |k    S r   r*   r\   s     r   r]   r]   ]   r^   r   )ltleeqnegtgec                        e Zd Zd Zd Zd ZdS )
VectorTestc                 D    t           |         D ]} | j        ||g|R   d S r   )opmapassertRaises)r
   erroropnameargsops        r   	checkfailzVectorTest.checkfailb   s?    - 	0 	0BDeR/$/////	0 	0r   c                 "   t           |         D ]} |||          }|                     t          |          t          |                     t          t          |                    D ]%}|                     ||         ||         u            &d S r   )rm   assertEqualr1   range
assertTrue)r
   rp   rB   rC   expresrr   realresr4   s           r   
checkequalzVectorTest.checkequalf   s    - 	9 	9BbAhhGS\\3v;;7773w<<(( 9 9
fQi 788889		9 	9r   c                 f   t          t          d                    }t          t          d                    }t          D ]}|                     t          |||            t          t          d                    }ddgz  }|t          |          ft          |          |ft          |          t          |          fg}|D ]\  }}|                     d||g d           |                     d||g d           |                     d||g d	           |                     d
||g d           |                     d||g d           |                     d||g d           t                                          D ]2}|D ]-}|                     t          t           |||                     .3d S )N         rd   )TTFFFre   )TTTFFrf   )FFTFFrg   )TTFTTrh   )FFFTTri   )FFTTT)r,   rv   rm   rs   rX   listrz   valuesrn   r:   bool)r
   rB   rC   rp   rq   opsrr   s          r   
test_mixedzVectorTest.test_mixedo   s    588588 	5 	5FNN:vq!4444qNNGF1IIAF1II0FG 	A 	AFQOOD!Q(K(K(KLLLOOD!Q(K(K(KLLLOOD!Q(K(K(KLLLOOD!Q(K(K(KLLLOOD!Q(K(K(KLLLOOD!Q(K(K(KLLL||~~ A A A AB%%irr!Qxx@@@@AA	A 	Ar   N)r'   r(   r)   rs   rz   r   r*   r   r   rk   rk   `   sF        0 0 09 9 9A A A A Ar   rk   c                        e Zd Zd Zd Zd ZdS )
NumberTestc           
         t          d          D ]}t          d          D ]}t          t          fD ]}t          t          fD ]}}||cxk    rt          k    rn n ||          } ||          }t                                          D ]5}|D ]0} |||          }	 |||          }
|                     |	|
           16~d S )Nr}   )rv   intr   rm   r   ru   )r
   rB   rC   typeatypebtatbr   rr   realoutcometestoutcomes              r   
test_basiczNumberTest.test_basic   s&    q 	K 	KA1XX K K!6] 
K 
KE"%v 	K 	K %,,,,,,,,,$"U1XX"U1XX#(<<>> K KC&) K K.0bAhh.0bRjj $ 0 0k J J J JKK	K
KK	K 	Kr   c                     t           t          fD ]m}t           t          fD ]\} ||          } ||          }t          |         D ]6}	 |	||          }
t          |
d|
          }
|                     |
|u            7]nd S )Nr	   )r   r   rm   getattrrw   )r
   rp   rB   rC   rx   r   r   r   r   rr   ry   s              r   
checkvaluezNumberTest.checkvalue   s    6] 	7 	7Ev 7 7U1XXU1XX- 7 7B bRjjG%gsG<<GOOGv$5666677	7 	7r   c                 f   |                      dddd           |                      dddd           |                      dddd           |                      dddd           |                      dddd           |                      d	ddd           |                      ddd
d           |                      ddd
d           |                      ddd
d           |                      ddd
d           |                      ddd
d           |                      d	dd
d           |                      dd
dd           |                      dd
dd           |                      dd
dd           |                      dd
dd           |                      dd
dd           |                      d	d
dd           d S )Nrd   r   Fre   Trf   rg   rh   ri      )r   r%   s    r   test_valueszNumberTest.test_values   s   aE***aD***aD***aE***aE***aD***aD***aD***aE***aD***aE***aE***aE***aE***aE***aD***aD***aD*****r   N)r'   r(   r)   r   r   r   r*   r   r   r   r      sD        K K K$7 7 7+ + + + +r   r   c                   @    e Zd Zd Zd Zej        d             Zd ZdS )MiscTestc                       G  fdd          } |            } |            }                      ||k     d                                 ||k    d                                 ||k    d           d S )Nc                   @    e Zd Zd Zd Zd Z fdZ fdZ fdZdS )&MiscTest.test_misbehavin.<locals>.Misbc                     dS Nr   r*   self_r   s     r   r   z-MiscTest.test_misbehavin.<locals>.Misb.__lt__       QQr   c                     dS r   r*   r   s     r   r   z-MiscTest.test_misbehavin.<locals>.Misb.__gt__   r   r   c                     dS r   r*   r   s     r   r   z-MiscTest.test_misbehavin.<locals>.Misb.__eq__   r   r   c                 2                         d           d S NzThis shouldn't happenfailr   r   r
   s     r   r   z-MiscTest.test_misbehavin.<locals>.Misb.__le__       dii0G&H&H&H&H&Hr   c                 2                         d           d S r   r   r   s     r   r   z-MiscTest.test_misbehavin.<locals>.Misb.__ge__   r   r   c                 2                         d           d S r   r   r   s     r   r   z-MiscTest.test_misbehavin.<locals>.Misb.__ne__   r   r   N)	r'   r(   r)   r   r   r   r   r   r   r%   s   r   Misbr      sY        .........HHHHHHHHHHHHHHHHHr   r   r   )ru   )r
   r   rB   rC   s   `   r   test_misbehavinzMiscTest.test_misbehavin   s    	I 	I 	I 	I 	I 	I 	I 	I 	I 	I DFFDFF1a   Aq!!!1a     r   c                     dd l } G d dt                     G fdd          }d }||j        fD ]!}|                     | |                       "d S )Nr   c                       e Zd ZdS )MiscTest.test_not.<locals>.ExcNr'   r(   r)   r*   r   r   Excr              Dr   r   c                       e Zd Z fdZdS )MiscTest.test_not.<locals>.Badc                     r   r*   )r
   r   s    r   r;   z'MiscTest.test_not.<locals>.Bad.__bool__       	r   N)r'   r(   r)   r;   r   s   r   Badr      .              r   r   c                     |   d S r   r*   )bads    r   dozMiscTest.test_not.<locals>.do   s    GGGGr   )operator	Exceptionnot_rn   )r
   r   r   r   funcr   s        @r   test_notzMiscTest.test_not   s     		 	 	 	 	) 	 	 		 	 	 	 	 	 	 	 	 		 	 	 ' 	0 	0Dc4////	0 	0r   c                    ddl m}  |            } |            }|                    |           |                    |           |                     t          t
          j        ||           |                     t          t
          j        ||           |                     t          t
          j        ||           |                     t          t
          j	        ||           |                     t          t
          j
        ||           |                     t          t
          j        ||           |                    d           |                     ||k                |                     ||k               |                     t          t
          j        ||           |                     t          t
          j	        ||           |                     t          t
          j
        ||           |                     t          t
          j        ||           |                    d           |                     t          t
          j        ||           |                     t          t
          j        ||           |                    dd           |                    dd           |                     ||k                |                     ||k               |                     ||k                d S )Nr   )UserList         )collectionsr   appendrn   RecursionErrorr   rf   rg   rd   re   rh   ri   rw   insert)r
   r   rB   rC   s       r   test_recursionzMiscTest.test_recursion   sT    	)(((((HJJHJJ		.(+q!<<<.(+q!<<<.(+q!<<<.(+q!<<<.(+q!<<<.(+q!<<<	 	Q!V%%%Q.(+q!<<<.(+q!<<<.(+q!<<<.(+q!<<<	.(+q!<<<.(+q!<<<	B	BQ!V%%%QAr   c                     G d d          d dfd dfd dfd	 d
fd dfd dfd dfd dfd dfd dffddffddffddfg}t          |          D ]|\  }}|                     |          5  |                     t          |d                   5   |d                      d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   }d S ) Nc                       e Zd ZdS )-MiscTest.test_exception_message.<locals>.SpamNr   r*   r   r   Spamr     r   r   r   c                      dd k     S N*   r*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  
    R$Y r   z'<' .* of 'int' and 'NoneType'c                      d dk     S r   r*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  s
    TBY r   z'<' .* of 'NoneType' and 'int'c                      dd k    S r   r*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  r   r   z'>' .* of 'int' and 'NoneType'c                      dd k     S )Nfoor*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  s
    UT\ r   z'<' .* of 'str' and 'NoneType'c                      ddk    S )Nr   i  r*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>	  s
    Uc\ r   z'>=' .* of 'str' and 'int'c                      dd k    S r   r*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>
  
    R4Z r   z'<=' .* of 'int' and 'NoneType'c                      dd k    S r   r*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  r   r   z'>=' .* of 'int' and 'NoneType'c                      dg k     S r   r*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  
    R"W r   z'<' .* of 'int' and 'list'c                      dg k    S )Nr*   r*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  r   r   z'>' .* of 'tuple' and 'list'c                      d d k    S r   r*   r*   r   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  s
    TT\ r   z$'>=' .* of 'NoneType' and 'NoneType'c                                     dk     S r   r*   r   s   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  s    TTVVb[ r   z'<' .* of 'Spam' and 'int'c                       d              k     S r   r*   r   s   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  s    R$$&&[ r   z'<' .* of 'int' and 'Spam'c                  0                                k    S r   r*   r   s   r   r]   z1MiscTest.test_exception_message.<locals>.<lambda>  s    TTVVttvv% r   z'<=' .* of 'Spam' and 'Spam')testr   r   )	enumeratesubTestassertRaisesRegexr:   )r
   testsr4   r   r   s       @r   test_exception_messagezMiscTest.test_exception_message   s   	 	 	 	 	 	 	 	  AB AB AB!!#DE!!#@A!CD!CD_;<_=>!!#JK    "?@    "?@%%%%'FG
 !'' 	 	GAt1%%  ++ItAw??  DGIII                            	 	s6   5"CB4(C4B88C;B8<CC	C	N)	r'   r(   r)   r   r   r   
no_tracingr   r   r*   r   r   r   r      sa        ! ! !0 0 0    @    r   r   c                       e Zd Zd ZdS )DictTestc                 t   dd l }i }t          d          D ]3}|                    d          dz  ||                    d          dz  <   4t          |                                          }|                    |           i }|D ]
\  }}|||<   |                                }|dz   ||<   |                     ||           |                     ||           |                     ||           |                     ||k               dD ]/}	t          |	         D ]}
| 
                    t          |
||            0d S )Nr   2   d   y              ?g      ?)rd   re   rh   ri   )randomrv   	randranger   itemsshufflecopyru   rw   rm   rn   r:   )r
   r   imag1ar4   r   imag1bkr7   imag2rp   rr   s              r   
test_dictszDictTest.test_dicts  sm    	r 	H 	HA/5/?/?/D/DR/GF6##C((+,,V\\^^$$u 	 	DAqF1IIs7a((((((&&&%(((. 	@ 	@FFm @ @!!)R????@	@ 	@r   N)r'   r(   r)   r   r*   r   r   r   r     s(        @ @ @ @ @r   r   c                        e Zd Zd Zd Zd ZdS )ListTestc                    dg}|                      ||k     d           |                      ||k    d           |                      ||k    d           |                      ||k    d           |                      ||k    d           |                      ||k    d           ddg}|                      ||k     d           |                      ||k    d           |                      ||k    d           |                      ||k    d           |                      ||k    d           |                      ||k    d           d S )Nr   FT)assertIs)r
   r	   ys      r   test_coveragezListTest.test_coverage4  s8   Dac5!!!adD!!!adD!!!adE"""ac5!!!adD!!!Hac4   adD!!!adE"""adD!!!ac5!!!adE"""""r   c                      G d dt                      G fdd          } |            g} |            g}t          d         D ]}|                     |||           d S )Nc                       e Zd ZdS )#ListTest.test_badentry.<locals>.ExcNr   r*   r   r   r   r   H  r   r   r   c                       e Zd Z fdZdS )#ListTest.test_badentry.<locals>.Badc                     r   r*   )r
   r   r   s     r   r   z*ListTest.test_badentry.<locals>.Bad.__eq__K  r   r   N)r'   r(   r)   r   r   s   r   r   r  J  r   r   r   rf   )r   rm   rn   )r
   r   r	   r   rr   r   s        @r   test_badentryzListTest.test_badentryE  s    	 	 	 	 	) 	 	 		 	 	 	 	 	 	 	 	 	 SUUGSUUG+ 	- 	-Bc2q!,,,,	- 	-r   c                      G d d          } |            g} |            g}t           d         D ]"}|                      |||          d           #d S )Nc                       e Zd Zd ZdS )%ListTest.test_goodentry.<locals>.Goodc                     dS )NTr*   r   s     r   r   z,ListTest.test_goodentry.<locals>.Good.__lt__X  s    tr   N)r'   r(   r)   r   r*   r   r   Goodr  W  s#            r   r	  rd   T)rm   r   )r
   r	  r	   r   rr   s        r   test_goodentryzListTest.test_goodentryT  s    	 	 	 	 	 	 	 	 TVVHTVVH+ 	* 	*BMM""Q((D))))	* 	*r   N)r'   r(   r)   r   r  r
  r*   r   r   r   r   2  sA        # # #"- - -* * * * *r   r   __main__)unittestr   r   r   r   r,   rd   r   re   r   rf   r   rg   r   rh   r   ri   r   rm   TestCaserk   r   r   r   r   r'   mainr*   r   r   <module>r     s          ) ) ) ) ) ) ) ):0 0 0 0 0 0 0 0f X[(/
:X[(/
:X[(/
:X[(/
:X[(/
:X[(/
:	 	(A (A (A (A (A" (A (A (AT3+ 3+ 3+ 3+ 3+" 3+ 3+ 3+jW W W W Wx  W W Wt@ @ @ @ @x  @ @ @2-* -* -* -* -*x  -* -* -*` zHMOOOOO r   