
    ;e;                     h   	 d dl Z d dlZd dlZd dlmZ d dlmZmZ d Z G d d          Z	 G d d          Z
 G d	 d
          Z G d d          Z G d d          Z G d d          Z G d d          Zd dlmZ d Z G d de          Z G d de          Z G d de j                  ZdS )    N)support)	ALWAYS_EQNEVER_EQc              #      K   	 | D ]}|V  d S N seqnis     %/usr/lib/python3.11/test/seq_tests.pyiterfuncr      s-             c                       e Zd Z	 d Zd ZdS )Sequencec                     || _         d S r   r
   selfr
   s     r   __init__zSequence.__init__   s    			r   c                     | j         |         S r   r   r   r   s     r   __getitem__zSequence.__getitem__   s    y|r   N)__name__
__module____qualname__r   r   r   r   r   r   r      s5               r   r   c                   "    e Zd Z	 d Zd Zd ZdS )IterFuncc                 "    || _         d| _        d S Nr   r	   r   s     r   r   zIterFunc.__init__       	r   c                     | S r   r   r   s    r   __iter__zIterFunc.__iter__       r   c                     | j         t          | j                  k    rt          | j        | j                  }| xj         dz  c_         |S N   r   lenr
   StopIterationr   vs     r   __next__zIterFunc.__next__    >    6S^^##=%8Idf!r   Nr   r   r   r   r#   r-   r   r   r   r   r      sD        &        r   r   c                       e Zd Z	 d Zd ZdS )IterGenc                 "    || _         d| _        d S r   r	   r   s     r   r   zIterGen.__init__(   r    r   c              #   &   K   | j         D ]}|V  d S r   r   )r   vals     r   r#   zIterGen.__iter__+   s,      9 	 	CIIII	 	r   Nr   r   r   r   r#   r   r   r   r1   r1   &   s5        ?      r   r1   c                       e Zd Z	 d Zd ZdS )IterNextOnlyc                 "    || _         d| _        d S r   r	   r   s     r   r   zIterNextOnly.__init__1   r    r   c                     | j         t          | j                  k    rt          | j        | j                  }| xj         dz  c_         |S r&   r(   r+   s     r   r-   zIterNextOnly.__next__4   r.   r   N)r   r   r   r   r-   r   r   r   r7   r7   /   s5        &      r   r7   c                       e Zd Z	 d Zd ZdS )
IterNoNextc                 "    || _         d| _        d S r   r	   r   s     r   r   zIterNoNext.__init__<   r    r   c                     | S r   r   r"   s    r   r#   zIterNoNext.__iter__?   r$   r   Nr5   r   r   r   r;   r;   :   s5        !      r   r;   c                   "    e Zd Z	 d Zd Zd ZdS )
IterGenExcc                 "    || _         d| _        d S r   r	   r   s     r   r   zIterGenExc.__init__D   r    r   c                     | S r   r   r"   s    r   r#   zIterGenExc.__iter__G   r$   r   c                     ddz   d S )N   r   r   r"   s    r   r-   zIterGenExc.__next__I   s    	Qr   Nr/   r   r   r   r?   r?   B   sD        $        r   r?   c                   "    e Zd Z	 d Zd Zd ZdS )IterFuncStopc                     d S r   r   r   s     r   r   zIterFuncStop.__init__N   s    r   c                     | S r   r   r"   s    r   r#   zIterFuncStop.__iter__P   r$   r   c                     t           r   )r*   r"   s    r   r-   zIterFuncStop.__next__R   s    r   Nr/   r   r   r   rE   rE   L   sD                r   rE   )chainc                     	 t          t          d t          t          t	          |                                                   S )Nc                     | S r   r   )xs    r   <lambda>zitermulti.<locals>.<lambda>X   s    a r   )rI   mapr   r1   r   r   s    r   	itermultirO   V   s5    &ZZ'(4..*A*A!B!BCCDDDr   c                       e Zd Zd ZdS )
LyingTuplec              #      K   dV  d S r&   r   r"   s    r   r#   zLyingTuple.__iter__[         r   Nr   r   r   r#   r   r   r   rQ   rQ   Z   #            r   rQ   c                       e Zd Zd ZdS )	LyingListc              #      K   dV  d S r&   r   r"   s    r   r#   zLyingList.__iter___   rS   r   NrT   r   r   r   rW   rW   ^   rU   r   rW   c                       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 Zd Zd Zd Zd Zd ZdS )
CommonTestNc           	         g }dg}ddg}|                                  }|                      |          }|                      |          }|                      |          }|                      |          }|                      |          }	|                      |          }
|                      |          }|                      t          |                    } G d d          } ||          }|                      |          }|                     t          |          t          |                     d}|                      |          }|                     t          |          t          |                     ddt	          d          d	t	          d
dd          fD ]}t
          t          t          t          t          fD ]G}|                     |                       ||                    |                      |                     H|                     |                      t          |                    |                                             |                     |                      d dD                       |                      d                     |                     t          | j         t          |                     |                     t          | j         t          |                     |                     t          | j         t!          |                     |                     |                      t#          d                    |                      d                     |                     |                      t%          dg                    |                      dg                     |                     t                    5  |                      g            d d d            d S # 1 swxY w Y   d S )Nr   r'   c                        e Zd Zd Zd Zd ZdS ).CommonTest.test_constructors.<locals>.OtherSeqc                     || _         d S r   _OtherSeq__data)r   initseqs     r   r   z7CommonTest.test_constructors.<locals>.OtherSeq.__init__w   s    %r   c                 *    t          | j                  S r   )r)   r`   r"   s    r   __len__z6CommonTest.test_constructors.<locals>.OtherSeq.__len__y   s    4;'''r   c                     | j         |         S r   r_   r   s     r   r   z:CommonTest.test_constructors.<locals>.OtherSeq.__getitem__{   s    {1~%r   N)r   r   r   r   rc   r   r   r   r   OtherSeqr]   v   sA        & & &( ( (& & & & &r   re   zthis is also a sequence123   )dog333333?i  i     c              3      K   | ]}|V  d S r   r   ).0cs     r   	<genexpr>z/CommonTest.test_constructors.<locals>.<genexpr>   s"      +=+=!A+=+=+=+=+=+=r   )   )r'   ro   )unsupported_arg)	type2testtupleassertEqualr)   ranger   r   r1   rO   r   rE   assertRaises	TypeErrorr7   r;   ZeroDivisionErrorr?   rQ   rW   )r   l0l1l2uu0u1u2uuuu0uu1uu2r,   re   sv0vvgs                     r   test_constructorszCommonTest.test_constructorsf   s   SVNN^^B^^B^^B^^AnnR  nnR  nnR  NN588$$	& 	& 	& 	& 	& 	& 	& 	& HRLL^^AR#a&&)))%^^AR#a&&))) U4[[+uT$q7I7IJ 	P 	PA'+ J J  !!5!5t~~a7H7HIIIIT^^LOO<<dnn>N>NOOOT^^+=+=u+=+=+===t~~e?T?TUUUiaIIIiAGGG/AOOOO 	
4(8(8994>>$;O;OPPP	1#779L9LMMMy)) 	/ 	/NN2N...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   O11O58O5c                     |                      |                                            |                     |                     dg                     d S )N*   )assertFalserq   
assertTruer"   s    r   
test_truthzCommonTest.test_truth   sF    ))***t,,-----r   c           	         |                      g d          }t          t          |                    D ]G}|                     ||         |           |                     |t	          |                   |           Ht          t          |           d          D ]g}|                     ||         t          |          |z              |                     |t	          |                   t          |          |z              h|                     t          |j        t          |           dz
             |                     t          |j        t          |                     |                     t          |j        t          ddd                     |                                  }|                     t          |j        d           |                     t          |j        d           |                     t          |j                   |                      ddg          }|                     |d         d           |                     |d         d           |                     |d         d           |                     |d         d           |                     t          |j        d           |                     t          |j        d	           d S )
Nr   r'   ro   rC      r'   r   
      rC   )rq   rt   r)   rs   intru   
IndexErrorr   
ValueErrorslicerv   )r   r{   r   as       r   test_getitemzCommonTest.test_getitem   s]   NN???++s1vv 	+ 	+AQqT1%%%Qs1vvY****Aw## 	2 	2AQqT3q66!8,,,Qs1vvYAq1111*amc!ffWQY???*amSVV<<<*amU1R]]CCCNN*amQ777*amR888)Q]333NNB8$$1r"""1r"""2###2###*amR888*amQ77777r   c                 
   g d}|                      |          }|                     |dd         |                                             |                     |dd         |                      dg                     |                     |dd         |                      dg                     |                     |dd	         |           |                     |d	d         |                      g                      |                     |d d          |           |                     |dd          |                      g d
                     |                     |d d         |                      g d                     |                     |d d          |           |                     |d d d         |                      g d                     |                     |dd d         |                      ddg                     |                     |d d d         |                      g d                     |                     |d d d         |                      g d                     |                     |dd d         |                      ddg                     |                     |ddd         |                      g                      |                     |ddd         |                      dg                     |                     |ddd         |                      dg                     |                     |ddd         |                      ddg                     |                     |d d d         |                      dg                     |                     |dd         |                      g                      |                     |dd         |           |                     |ddd         |d d d                    |                     |ddd         |                      g                      |                     |ddd         |                      g d                     |                      g d          }|                     |t          dd           d         |                      g d                     |                     |dt          dd                   |                      ddg                     |                     |dd t          j                 |                      dg                     d S )Nr   r   r'   ro   r   r   rC   irh   )r'   ro   rC   r   r   r'   ro   )r   ro   r   )r   rC   ro   r'   r   )r   ro   r   ir   d         )rq   rs   powsysmaxsize)r   lr{   r   s       r   test_getslicezCommonTest.test_getslice   s   OONN11Q3!1!12221Q3!4!45552b54>>1##6#67775:***4:r(:(:;;;111q!!!1T6DNN<<<$@$@AAA46DNN999$=$=>>> 	222"""33Q3			!:!:;;;14a4$..!Q"8"899944R4$.."A"ABBB44R4$..";";<<<15b54>>1a&#9#9:::1Qr6DNN2$6$67771Qr6DNNA3$7$78881Qr6DNNA3$7$78881Qr6DNNAq6$:$:;;;66T6DNNA3$7$78883t9t~~b'9'9:::49q)))3tB;44R41114B;););<<<4A:yyy(A(ABBB NN;;;''S3ZZKN,dnnWWW.E.EFFFAs1SzzM+T^^QqE-B-BCCC1>ck>*DNNA3,?,?@@@@@r   c                 $   |                      g d          }|D ]}|                     ||           t          |          dz
  t          |          dz   fD ]}|                     ||           |                     t          |j                   d S )Nr   r'   )rq   assertInminmaxassertNotInru   rv   __contains__)r   r{   r   s      r   test_containszCommonTest.test_contains   s    NN999%% 	  	 AMM!QQ3q66!8# 	# 	#AQ"""")Q^44444r   c                 J   |                      t          |                     g                      |                     t          |                     dg                     |                     d|                     t          g                     |                      t          |                     g                      |                      t          |                     t          g                     |                     t          |                     t          g                     d S r&   )r   r   rq   r   r   r"   s    r   test_contains_fakezCommonTest.test_contains_fake   s     	DNN2$6$6777i!4!4555a445554>>"#5#5666DNNH:$>$>???h	{ ; ;<<<<<r   c                 ,    G d dt                      G fdd          }|                     d |            g          }|                     d|           |                      |            dg          }|                     |j        d           d S )Nc                       e Zd ZdS )3CommonTest.test_contains_order.<locals>.DoNotTestEqNr   r   r   r   r   r   DoNotTestEqr              Dr   r   c                       e Zd Z fdZdS )4CommonTest.test_contains_order.<locals>.StopComparesc                     r   r   )r   otherr   s     r   __eq__z;CommonTest.test_contains_order.<locals>.StopCompares.__eq__   s	    !!r   Nr   r   r   r   )r   s   r   StopComparesr      s.        " " " " " " "r   r   r'   )	Exceptionrq   r   ru   r   )r   r   
checkfirst	checklastr   s       @r   test_contains_orderzCommonTest.test_contains_order   s    	 	 	 	 	) 	 	 		" 	" 	" 	" 	" 	" 	" 	" 	" 	" ^^Q$788
a$$$NNLLNNA#677	+y'=qAAAAAr   c                    |                      t          |                                           d           |                      t          |                     g                     d           |                      t          |                     dg                    d           |                      t          |                     g d                    d           d S )Nr   r'   r   rC   )rs   r)   rq   r"   s    r   test_lenzCommonTest.test_len   s    T^^--..222T^^B//00!444T^^QC00111555T^^III6677;;;;;r   c                     |                      g d          }|                     t          |          d           |                     t          |          d           d S )Nr   r   ro   )rq   rs   r   r   r   r{   s     r   test_minmaxzCommonTest.test_minmax  sU    NN999%%Q###Q#####r   c                 
   |                      dg          }|                      ddg          }|                     |||                                  z              |                     ||                                  |z              |                     ||                      dg          z   |           |                     |                      dg          |z   |                      ddg                     |                     |                                  |dz             |                     |                                  d|z             |                     |                                  |dz             |                     |                                  d|z             |                     ||dz             |                     |d|z             |                     ||dz             |                     |d|z             |                     ||z   |dz             |                     ||z   d|z             |                     ||z   |dz             |                     ||z   d|z             |                     ||z   |z   |dz             |                     ||z   |z   d|z              G d d| j                   } |ddg          }|                     ||dz             |                     ||dz             d S )Nr   r'   r   ro   rC   c                       e Zd ZdS )(CommonTest.test_addmul.<locals>.subclassNr   r   r   r   subclassr     r   r   r   )rq   rs   assertIsNot)r   r}   r~   r   u3s        r   test_addmulzCommonTest.test_addmul  s   ^^QC  ^^QF##R$.."2"22333T^^--2333dnnaS1112666--2DNNB74K4KLLL))2a4000))1R4000))2a4000))1R4000RT"""QrT"""RT"""QrT"""B1%%%B"%%%B1%%%B"%%%Br2a4(((Br1R4(((	 	 	 	 	t~ 	 	 	Xq!fRT"""RT"""""r   c                 x   |                      ddg          }||                                  z  }|                     ||                      ddg                     ||                      ddg          z  }|                     ||                      g d                     ||                      ddg          z  }|                     ||                      g d                     |                      d	          }||                      d
          z  }|                     ||                      d                     d S )Nr   r'   ro   rC   r   r'   ro   rC   r   rj   )r   r'   ro   rC   r   rj   spameggsspameggsrq   rs   r   s     r   	test_iaddzCommonTest.test_iadd$  s#   NNAq6""	T^^DNNAq622333	T^^QF###DNN<<<88999	T^^QF###DNN+=+=+=>>???NN6""	T^^F###DNN:6677777r   c                     |                      ddg          }|dz  }|                     ||                      g d                     |dz  }|                     ||                      g                      d S )Nr   r'   rC   )r   r'   r   r'   r   r'   r   r   s     r   	test_imulzCommonTest.test_imul1  sz    NNAq6""	QDNN+=+=+=>>???	QDNN2../////r   c           	           G d d| j                   }|                     t          t           |d                              d           d S )Nc                       e Zd Zd ZdS )/CommonTest.test_getitemoverwriteiter.<locals>.Tc                 &    t          |          dz   S )Nz!!!)str)r   keys     r   r   z;CommonTest.test_getitemoverwriteiter.<locals>.T.__getitem__;  s    3xx%''r   N)r   r   r   r   r   r   r   Tr   :  s#        ( ( ( ( (r   r   )r'   ro   r'   )rq   rs   nextiter)r   r   s     r   test_getitemoverwriteiterz$CommonTest.test_getitemoverwriteiter8  sb    	( 	( 	( 	( 	( 	( 	( 	( 	d11U88nn--q11111r   c                    t          d          D ]}t          t          |                    }t          dd          D ]D}|                     |                     ||z            |                     |          |z             E|                     |                     |          dz  |                     g                      |                     t	          |          t	          |dz                       d S )Nr   r   rj   r'   )rt   rr   rs   rq   id)r   mr   ns       r   test_repeatzCommonTest.test_repeat?  s    q 	- 	-AeAhhA2q\\ K K  !!4!4dnnQ6G6G6IJJJJT^^A..3T^^B5G5GHHHRUUBqsGG,,,,	- 	-r   c                    t           j        dk    ro|                     dg          }|dz  }|                     t          |j        d           t          |d          r%|                     t          |j        d           d S d S d S )Nir   i   __imul__)r   r   rq   ru   MemoryError__mul__hasattrr   )r   rL   s     r   test_bigrepeatzCommonTest.test_bigrepeatG  s    ;*$$s##AJAk19e<<<q*%% B!!+qz5AAAAA %$B Br   c           	         |                      ddg          }|                     |                    d          d           |                     |                    d          d           |                     |                    d          d           |                     |                    d          d           |                     t          |j        d           |                     t          |j        d           |                     |                    t          dd                    |                      dg                     |                     |                    t          dd	                    |                      dg                     |                     |                    t          dd	                    |                      ddg                     |                     |                    t          dd                    |                      ddg                     |                     |                    t          dd
                    |                      g                      |                     t          |j        t          ddd                     |                     t          |j        d           d S )Nr   r   r   r'   r   r   r   rC   ro   rj   rL   )rq   rs   r   ru   r   r   r   rv   )r   r   s     r   test_subscriptzCommonTest.test_subscriptO  s1   NNB8$$q))2...q))2...r**B///r**B///*amR888*amQ777uQqzz22DNNB44H4HIIIuQqzz22DNNB44H4HIIIuQqzz22DNNB84L4LMMMuQqzz22DNNB84L4LMMMuQqzz22DNN24F4FGGG*amU1b!__EEE)Q]C88888r   c                    |                      g d          dz  }|                     |                    d          d           |                     |                    d          d           |                     |                    d          d           |                     |                    t                    d           |                     |                      t          t          g                              d          d           |                     |                      t          t          g                              t                    d           |                     |                      t          t          g                              t                    d           |                     t          |j                    G d dt                     G fd	d
          }|                     |j         |                       d S )Nr   rC   r   r'   	   ro   c                       e Zd ZdS )%CommonTest.test_count.<locals>.BadExcNr   r   r   r   BadExcr   l  r   r   r   c                       e Zd Z fdZdS )%CommonTest.test_count.<locals>.BadCmpc                 (    |dk    r
             dS Nro   Fr   r   r   r   s     r   r   z,CommonTest.test_count.<locals>.BadCmp.__eq__p      A:: &((Nur   Nr   r   s   r   BadCmpr   o  .              r   r   )rq   rs   countr   r   ru   rv   r   )r   r   r   r   s      @r   
test_countzCommonTest.test_count_  s   NN999%%a'Q'''Q'''Q'''++Q///I(>??EEaHH!LLLI(>??EEhOOQRSSS8(<==CCINNPQRRR)QW---	 	 	 	 	Y 	 	 		 	 	 	 	 	 	 	 	 	 	&!'668844444r   c                 
   |                      ddg          }|                     |                    d          d           |                     |                    d          d           |                     t          |j        d           |                      g d          }|                     |                    d          d           |                     |                    d          d           |                     |                    dd          d           |                     |                    dd          d           |                     |                    dd          d           |                     |                    ddd          d           |                     t          |j        ddd           |                     |                    t                    d           |                     |                      t          t          g                              d          d           |                     |                      t          t          g                              t                    d           |                     t          |                      t          t          g          j        t                     |                     t          |j                    G d	 d
t                     G fdd          }|                      g d          }|                     |j         |                       |                      g 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t          j        z  dt          j        z            d           |                     t          |j        ddt          j        z  dt          j        z             |                     t          |j        ddd           d S )Nr   r'   ro   )r   r   r   r   r'   ro   r   irC   r   c                       e Zd ZdS )%CommonTest.test_index.<locals>.BadExcNr   r   r   r   r   r     r   r   r   c                       e Zd Z fdZdS )%CommonTest.test_index.<locals>.BadCmpc                 (    |dk    r
             dS r   r   r   s     r   r   z,CommonTest.test_index.<locals>.BadCmp.__eq__  r   r   Nr   r   s   r   r   r     r   r   r   r   r   r   )rq   rs   indexru   r   r   r   r   rv   r   r   r   )r   r{   r   r   r   s       @r   
test_indexzCommonTest.test_indexw  s   NNAq6""Q'''Q'''*agq111NN///00Q'''Q'''A***S))1---A***Aq))1---*agq!S999++Q///I(>??EEaHH!LLLI(>??EEhOOQRSSS*dnnh5I&J&J&PR[\\\)QW---	 	 	 	 	Y 	 	 		 	 	 	 	 	 	 	 	 	 NN<<<((&!'6688444NN///00Q'''A***B+++S))1---A***B+++Aq))1---B++Q///Bs{NAckMBBAFFF*agq!CK-3;OOO*agq!S99999r   c                 L   |                      g d          }t          t          j        dz             D ]o}t          j        t          j        ||                    }|                     ||           |                     t          |          t          |                     pd S )N)r   rj         r'   )	rq   rt   pickleHIGHEST_PROTOCOLloadsdumpsrs   assertNotEqualr   )r   lstprotolst2s       r   test_picklezCommonTest.test_pickle  s    nn\\\**62Q677 	3 	3E<S% 8 899DT3'''4"S''2222	3 	3r   c                     t          j        | t          | j                   t          j        | t          | j                   d S r   )r   check_free_after_iteratingr   rq   reversedr"   s    r   test_free_after_iteratingz$CommonTest.test_free_after_iterating  s6    *4t~FFF*44>JJJJJr   )r   r   r   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   r   r   rZ   rZ   b   sV       I// // //b. . .8 8 84#A #A #AJ5 5 5	= 	= 	=B B B< < <$ $ $
# # #88 8 80 0 02 2 2- - -B B B9 9 9 5 5 50-: -: -:^3 3 3K K K K Kr   rZ   )unittestr   r  testr   test.supportr   r   r   r   r   r1   r7   r;   r?   rE   	itertoolsrI   rO   rr   rQ   listrW   TestCaserZ   r   r   r   <module>r     s=    



        , , , , , , , ,  
                     	 	 	 	 	 	 	 	                           E E E              MK MK MK MK MK" MK MK MK MK MKr   