
    <e                       d dl mZmZmZmZmZmZmZmZm	Z	 d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ 	 d dlZd dlZn# e$ r dZY nw xY w G d de          Z G d de          Z G d	 d
ej                  Zd Ze 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 )    )	
gc_collect
bigmemtest_2Gcpython_onlycaptured_stdoutcheck_disallow_instantiationis_emscriptenis_wasiSHORT_TIMEOUTN)Scanner)proxyc                        e Zd Z fdZ xZS )Sc                 `    t          t                                          |                    S N)r   super__getitem__selfindex	__class__s     #/usr/lib/python3.11/test/test_re.pyr   zS.__getitem__   #    $$U++,,,    __name__
__module____qualname__r   __classcell__r   s   @r   r   r      8        - - - - - - - - -r   r   c                        e Zd Z fdZ xZS )Bc                 `    t          t                                          |                    S r   )r#   r   r   r   s     r   r   zB.__getitem__"   r   r   r   r    s   @r   r#   r#   !   r!   r   r#   c                   n   e Zd ZddZddZdd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 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/ Z0d0 Z1d1 Z2d2 Z3d3 Z4d4 Z5d5 Z6d6 Z7d7 Z8dde9j:        fd8Z;e<j=        e<j>        z   d9z   Z?d: Z@d; ZAd< ZBd= ZCd> ZDd? ZEd@ ZFdA ZGdB ZHdC ZIdD ZJdE ZKdF ZLdG ZMdH ZNdI ZOdJ ZPdK ZQdL ZRdM ZSdN ZTdO ZUdP ZVdQ ZWdR ZXdS ZYdT ZZdU Z[dV Z\dW Z]dX Z^dY Z_dZ Z`d[ Zad\ Zbd] Zcd^ Zdd_ Zed` Zfda Zgdb Zhdc Zidd Zjde Zk elemdfg          dh             Zn elemdig          dj             Zodk Zpdl Zqdm Zrdn Zsdo Ztdp Zudq Zvdr Zwds Zxdt Zy ezj{        e|pe}du          dv             Z~dw Zdx Z ezj{        e|pe}du          dy             Zdz Zd{ Zd| Zd} Zd~ Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z ezj{        edu d          d             ZdS )ReTestsNc                 `                           ||            fd ||           d S )Nc                     t          |t          t          f          r$t          | |          D ]\  }} ||           d S                     t          |           t          |                     d S r   )
isinstancetuplelistzipassertIstype)actualexpectxymsgrecurser   s       r   r4   z)ReTests.assertTypedEqual.<locals>.recurse)   s{    &5$-00 ?// " "DAqGAqMMMM" " d6llDLL#>>>>>r   )assertEqual)r   r/   r0   r3   r4   s   `  `@r   assertTypedEqualzReTests.assertTypedEqual'   sZ    ---	? 	? 	? 	? 	? 	? 	? 	r   c                 x   |                      t          j                  5 }t          j        |           d d d            n# 1 swxY w Y   |                     |          5  |j        }|                     |j        |           ||                     |j        |           d d d            d S # 1 swxY w Y   d S )N)pattern)	assertRaisesreerrorcompilesubTest	exceptionr5   r3   pos)r   r8   errmsgr?   cmerrs         r   checkPatternErrorzReTests.checkPatternError1   s.   rx(( 	 BJw	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 \\'\** 	/ 	/,CSWf---  #...		/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s$   AAA"A B//B36B3c                 ~   |                      t          j                  5 }t          j        |||           d d d            n# 1 swxY w Y   |                     ||          5  |j        }|                     |j        |           ||                     |j        |           d d d            d S # 1 swxY w Y   d S )N)r8   repl)	r9   r:   r;   subr=   r>   r5   r3   r?   )r   r8   rE   stringr@   r?   rA   rB   s           r   checkTemplateErrorzReTests.checkTemplateError:   s4   rx(( 	*BF7D&)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*\\'\55 	/ 	/,CSWf---  #...		/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s$   AA
A%A B22B69B6c                 B   t          d          }t          j        d|          }|                     t                    5  |                    d           d d d            n# 1 swxY w Y   t          |           ~t                       |                    d           d S )N   x   as  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)	bytearrayr:   finditerr9   BufferErrorextendr+   r   )r   bits      r   test_keep_bufferzReTests.test_keep_bufferC   s    dOO[q!!{++ 	 	HHX	 	 	 	 	 	 	 	 	 	 	 	 	 	 	R	s   A!!A%(A%c                     d}t          j        d          }t          |          }|                     |                    d          |                    d                     d S )NQabbbcRzab+c)r:   r<   r   r5   findall)r   sr1   r2   s       r   test_weakrefzReTests.test_weakrefN   sU    Jv!HH9--qyy/C/CDDDDDr   c                 ^   |                      t          j        dd                              d          d           |                      t          j        dd                                          d           |                      t          j        dd                              d          d           |                      t          j        dd                                          d           |                     t          j        dd                     |                      t          j        d	d
                              d          d           |                      t          j        d	d
                                          d           |                      t          j        dd                              d          d           |                      t          j        dd                                          d           |                     t          j        dd
                     d S )Nx*axxr   r   r   zx+      r1   aaaza*xxxxxxar   r^   a+)r5   r:   searchspanassertIsNonematchr   s    r   test_search_star_pluszReTests.test_search_star_plusT   s   4//44Q77@@@4//4466???4//44Q77@@@4//4466???")C//000$..33A66???$..3355v>>>$//44Q77@@@$//4466???"(4//00000r   c                 ,   |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd	                                          d           |                      t          j        dd
                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           dS )zDTest Branching
        Test expressions using the OR ('|') operator.z(ab|ba)abr      baz(abc|bac|ca|cb)abcrb   baccacbz((a)|(b)|(c))ar   r]   rP   cNr5   r:   rg   re   rh   s    r   test_branchingzReTests.test_branching`   s    	)T2277996BBB)T2277996BBB"3U;;@@BB	! 	! 	!"3U;;@@BB	! 	! 	!"3T::??AA	! 	! 	!"3T::??AA	! 	! 	!/377<<>>GGG/377<<>>GGG/377<<>>GGGGGr   c                 j    t          |                    d                    }t          |dz             S )Nr   r]   )intgroupstr)r   matchobj	int_values      r   bump_numzReTests.bump_numq   s-    q))**	9q=!!!r   c           
         |                      t          j        ddd          d           |                      t          j        dt          d          t          d                    d           |                      t          j        ddd          d           |                      t          j        dt	          d          t	          d                    d           |                      t          j        dt          d          t          d                    d           |                      t          j        dt          d          t          d                    d           d	D ]/}|                     t          j        |dd
|z            d           0|                     t          j        ddd          d           |                     t          j        d| j        d          d           |                     t          j        d| j        dd          d           |                     t          j        d| j        dd          d           |                     t          j        dd d          d           |                     t          j        ddd          d           d|                     t          j        dd          d           |                     t          j        d	                    dd          d                     |                     t          j        dfdd                     |                     t          j        dd d          d!           |                     t          j        dd"d          d!           |                     t          j        d#d$d          d!           |                     t          j        d#d%d          d!           |                     t          j        d&d'd          d!           |                     t          j        dd(d          d)           |                     t          j        dd)d          d)           |                     t          j        dd)d          t          d*          t          d+          z   t          d,          z   t          d-          z   t          d.          z   t          d/          z   t          d0          z              d1D ]}|                     |          5  |                     t          j                  5  |                     t          j        dd|z   d          d|z              d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     t          j        d2d3d4          d5           d S )6Nr2   rs   xyzxaz   yrK      xyzs   xaz   àu   аu   𝒜zx%sz(?i)b+r1   	bbbb BBBBx x\d+z08.2 -2 23x99yz9.3 -3 24x100yr^   z9.3 -3 23x99ycount.c                     dS )N\n ms    r   <lambda>z+ReTests.test_basic_re_sub.<locals>.<lambda>   s    u r   r   
z\1\1z(.)xx\\\c                     S r   r   )r   rV   s    r   r   z+ReTests.test_basic_re_sub.<locals>.<lambda>   s     r   (?P<a>x)z
\g<a>\g<a>xxxxz
\g<a>\g<1>
(?P<unk>x)z\g<unk>\g<unk>z
\g<1>\g<1>z()xz
\g<0>\g<0>z\t\n\v\r\f\a\bz	
	   
                  ,cdehijklmopqsuwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz^\s*XtestXtest)r6   r:   rF   r   r#   rL   
memoryviewr5   r~   replacechrr=   r9   r;   )r   r2   ru   rV   s      @r   test_basic_re_subzReTests.test_basic_re_subu   s   bfS#u55u===bfS!C&&!E((;;UCCCbfT488&AAAbfT1T77AfII>>GGGbfT9T??If<M<MNNPVWWWbfT:d+;+;Z=O=OPPRXYYY1 	@ 	@ARVAsFQJ77????#{;;UCCC7GHH)	+ 	+ 	+7GKK(	* 	* 	*7GqQQQ(	* 	* 	* 	__c::EBBBUC00$777q#..555qyyu'='=sCCQGGG{{{{C88!<<<
M4@@&III
M4@@&III.?FFOOOmTBBFKKK}d;;VDDD%6<<>NOOO%5s;;=MNNN%5s;;a&&R.R0R8R@QGAN	Q 	Q 	Q? 	K 	KAa K K&&rx00 K K$$RVC3%?%?JJJK K K K K K K K K K K K K K KK K K K K K K K K K K K K K K 	f55w?????s6    V41U1%V1U55V8U59VV	V	c                 Z    |                      t          j        ddd          d           d S )Nr   z\g<1>\g<1>\br   zxxxxr5   r:   rF   rh   s    r   test_bug_449964zReTests.test_bug_449964   s7    EE#	% 	% 	% 	% 	%r   c                 V   |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           d S )Nz\r\nr   z
abc
def
zabc
def
z
r   r   rh   s    r   test_bug_449000zReTests.test_bug_449000   s    0@AA%	' 	' 	'/?@@%	' 	' 	'/?@@%	' 	' 	'.>??%	' 	' 	' 	' 	'r   c                    t          j        d          }|                     t          t           j        |dt           j                   |                     t          t           j        |dt           j                   |                     t          t           j        |dt           j                   |                     t          t           j        |t           j                   d S )Nr   A)r:   r<   r9   
ValueErrorrg   Ird   rU   r   r8   s     r   test_bug_1661zReTests.test_bug_1661   s    *S//*bhbdCCC*bi#rtDDD*bj'3EEE*bj'24@@@@@r   c                 .    t          j        d           d S )Nz(?P<quote>)(?(quote)))r:   r<   rh   s    r   test_bug_3629zReTests.test_bug_3629   s    

*+++++r   c                    |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        dd	d          d
           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d
           |                      t          j        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d0dd'd!           |                     dd1dd)d!           |                     dd2dd3d!           |                     dd"d4d#d!           |                      t          j        d5d&d          d           |                      t          j        d6d/d7          d8           |                      t          j        d6d0d7          d9           d S ):Nr1   \0 z\000z\001z\008 8z\009z 9z\111r   z\117Oz\377   ÿz\1111I1z\00z\07\08z\09z\0az az\400z0octal escape value \400 outside of range 0-0o377r   z\777z0octal escape value \777 outside of range 0-0o377z\1zinvalid group reference 1r]   z\8zinvalid group reference 8z\9zinvalid group reference 9z\11zinvalid group reference 11z\18zinvalid group reference 18z\1az\90zinvalid group reference 90z\99zinvalid group reference 99z\118z\11az\181z\800zinvalid group reference 80 z(((((((((((x)))))))))))z((((((((((y))))))))))(.)r   xz8xza)r5   r:   rF   rH   rh   s    r    test_sub_template_numeric_escapez(ReTests.test_sub_template_numeric_escape   sx   UC00$777Wc22F;;;Wc22F;;;Wc22J???Wc22J???Wc22F;;;Wc22F;;;Wc22F;;;Xs33W===Xs33\BBBVS116:::VS116:::VS11:>>>VS11:>>>VS11:>>>Wc!123	5 	5 	5 	Wc!123	5 	5 	5 	UC1LaPPPUC1LaPPPUC1LaPPPVS2NPQRRRVS2NPQRRRVS2MqQQQVS2NPQRRRVS2NPQRRRWc3OQRSSSWc3OQRSSSWc3OQRSSSWc3OQRSSSUB0KQOOO 	 963GGMMM :GUKK	  	  	  :GUKK	  	  	  	  	 r   c                    |                      t          j        ddd          d           |                      t          j        dddd          d           |                      t          j        dddd          d           d S )Nrs   rP   aaaaabbbbbr]   baaaar   r   rh   s    r   test_qualified_re_subzReTests.test_qualified_re_sub   s{    S'22G<<<S'155w???S';;;WEEEEEr   c                 Z    |                      t          j        ddd          d           d S )Nz(\S)\s+(\S)z\1 \2zhello  therezhello therer   rh   s    r   test_bug_114660zReTests.test_bug_114660   s7    .II&	( 	( 	( 	( 	(r   c                    t          j        d           t          j        d           t          j        d           t          j        d           t          j        d           t          j        d           d                    d t          d	d
          D                       }d|z  }|                     t          j        |d                                          d           d S )Nz(?P<a>x)(?P=a)(?(a)y)z(?P<a1>x)(?P=a1)(?(a1)y)z(?P<a1>x)\1(?(1)y)s   (?P<a1>x)(?P=a1)(?(a1)y)u   (?P<µ>x)(?P=µ)(?(µ)y)uf   (?P<𝔘𝔫𝔦𝔠𝔬𝔡𝔢>x)(?P=𝔘𝔫𝔦𝔠𝔬𝔡𝔢)(?(𝔘𝔫𝔦𝔠𝔬𝔡𝔢)y)|c              3   $   K   | ]}d ||fz  V  dS zx(?P<a%d>%x)yNr   .0is     r   	<genexpr>z/ReTests.test_symbolic_groups.<locals>.<genexpr>   +      KKA!Q/KKKKKKr   r]      z(?:%s)(?(200)z|t)xc8yzr      )r:   r<   joinranger5   rg   re   r   pats     r   test_symbolic_groupszReTests.test_symbolic_groups   s    

+,,,

.///

()))

.///

-...

{|||hhKKq'9J9JKKKKK!C'#w//4466?????r   c                 t   |                      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           |                     t          d+          5 }t          j        d,           d d d            n# 1 swxY w Y   |                     |j        t                     |                     t          d+          5  |                      d-d.d           d d d            n# 1 swxY w Y   |                     t          d/          5  |                      d0d.d           d d d            d S # 1 swxY w Y   d S )1Nz(?P<a>)(?P<a>)z6redefinition of group name 'a' as group 2; was group 1z(?P<a>(?P=a))cannot refer to an open groupr   z(?Pxy)zunknown extension ?Pxz(?P<a>)(?P=amissing ), unterminated namer   z(?P=missing group name   z(?P=)z(?P=1)zbad character in group name '1'z(?P=a)zunknown group name 'a'z(?P=a1)zunknown group name 'a1'z(?P=a.)z bad character in group name 'a.'z(?P<)missing >, unterminated namez(?P<az(?P<z(?P<>)z(?P<1>)z(?P<a.>)z(?(r^   z(?())z(?(a))z(?(-1)) bad character in group name '-1'z(?(1a))z bad character in group name '1a'z(?(a.))u	   (?P<©>x)    bad character in group name '©'u   (?P=©)u   (?(©)y)z6bad character in group name '\\xc2\\xb5' at position 4s	   (?P<µ>x)s   (?P=µ)zunknown group name '\xc2\xb5'6bad character in group name '\\xc2\\xb5' at position 3s   (?(µ)y)rC   assertWarnsRegexDeprecationWarningr:   r<   r5   filename__file__r   ws     r   test_symbolic_groups_errorsz#ReTests.test_symbolic_groups_errors  s   0 -	. 	. 	. 	/>	D 	D 	Dy*ABBB0NPRSSSw(<a@@@x)=qAAAy*KQOOOy*BCCCz+DEEEz+MqQQQx)GKKKx)GKKKw(<a@@@y*>BBBz+LaPPP{,NPQRRRv';Q???x)=qAAAy*BAFFFz+MqQQQz+MqQQQz+MqQQQ{,NPQRRRy*LaPPPz+MqQQQ""#5$45 5 	+89J)***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	X...""#5$45 5 	H 	H ""#3#CQH H H	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H
 ""#5$45 5 	H 	H ""#4#CQH H H	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	Hs6   I88I<?I<>K""K&)K&L--L14L1c                 X   |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        d	d
d          d           |                      t          j        ddd          d           d                    d t	          dd          D                       }|                      t          j        |dd          d           d S )Nz(?P<a>x)|(?P<b>y)z\g<b>r   r   \2s	   (?P<a1>x)s   \g<a1>   xxu	   (?P<µ>x)u   \g<µ>u#   (?P<𝔘𝔫𝔦𝔠𝔬𝔡𝔢>x)u    \g<𝔘𝔫𝔦𝔠𝔬𝔡𝔢>r   c              3   $   K   | ]}d ||fz  V  dS r   r   r   s     r   r   z-ReTests.test_symbolic_refs.<locals>.<genexpr>7  r   r   r]   r   z\g<200>	xc8yzxc8yc8zc8)r5   r:   rF   r   r   r   s     r   test_symbolic_refszReTests.test_symbolic_refs/  s    3XtDDbIII 3UDAA2FFFj%@@%HHHY==tDDD EGjlpqqswxxxhhKKq'9J9JKKKKKZ==wGGGGGr   c                    |                      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           |                     t          d          5  t          j        ddd           d d d            n# 1 swxY w Y   |                      ddddd           |                     t          d          5 }t          j        ddd           d d d            n# 1 swxY w Y   |                     |j        t                     |                     t          d          5  t          j        ddd           d d d            n# 1 swxY w Y   |                     t          d          5  t          j        ddd           d d d            n# 1 swxY w Y   |                      dddd d           |                     t          d!          5 }|                     t          d"          5  t          j        d#d$d%           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     |j        t                     |                      dd&dd'd           |                      dd(dd)d           |                     t          d*          5  t          j        dd+d           d d d            d S # 1 swxY w Y   d S ),Nr   z\g<ar   r   r^   z\g<r   z\gz	missing <rm   z\g<a a>z!bad character in group name 'a a'z\g<>z\g<1a1>z!bad character in group name '1a1'z\g<2>invalid group reference 2r   r]   zunknown group name 'ab'z\g<ab>z\g<-1>r   z/bad character in group name '\+1' at position 3z\g<+1>z/bad character in group name '1_0' at position 3z()()()()()()()()()()z\g<1_0>z/bad character in group name ' 1 ' at position 3z\g< 1 >u   \g<©>r   r   u   unknown group name 'Âµ's   (?P<a>x)s   \g<µ>r   u   \g<㊀>!   bad character in group name '㊀'u   \g<¹>    bad character in group name '¹'u/   bad character in group name '१' at position 3u   \g<१>)
rH   assertRaisesRegex
IndexErrorr:   rF   r   r   r5   r   r   r   s     r   test_symbolic_refs_errorsz!ReTests.test_symbolic_refs_errors:  s   
GT >	C 	C 	C
FD 4a	9 	9 	9
E4aHHH
J CQ	H 	H 	H
GT 4a	9 	9 	9
J CQ	H 	H 	H
Hd ;Q	@ 	@ 	@
E4 ;Q	@ 	@ 	@##J0IJJ 	0 	0F:y$///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0
It BA	G 	G 	G""#5$45 5 	089F:y$///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	X...""#5$45 5 	. 	. F7J---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. ""#5$45 5 	1 	1 F:z4000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	
It BA	G 	G 	G""#5$45 5 	=89''
4STT = ={$4e<<<= = = = = = = = = = = = = = =	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=
 	X...
J CQ	H 	H 	H
It BA	G 	G 	G""#5$45 5 	1 	1 F:z4000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   $DDDE))E-0E-/GGG8HH"HJ06JJ0J	J0 J	!J00J47J4(MMMc                    |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        ddd          d           |                      t          j        d	dd          d
           |                      t          j        d	ddd          d           |                      t          j        d	ddd          d           d S )Nr   r1   r   )r   rm   zb+)zx BBBBr]   r   )r   r   zb*)xxxyxzxr   rm   )xxxyzrm   r   )r5   r:   subnrh   s    r   test_re_subnzReTests.test_re_subnl  s    3<<jIIIsK88-HHHsE22J???sE22NCCCsE155|DDDsE;;;\JJJJJr   c                 J   dt          d          fD ]}|                     t          j        d|          g d           |                     t          j        d|          g d           |                     t          j        d|          g d           dt	          d          t          d          t          d          fD ]}|                     t          j        d	|          g d
           |                     t          j        d|          g d           |                     t          j        d|          g d           dD ]\  }}}d|d|d|}|                     t          j        d|          d||d|g           |                     t          j        d|          d|||g           |                     t          j        d|          dd|d|d|g           |                     t          j        dd          g d           |                     t          j        dd          g d           |                     t          j        dd          g d           |                     t          j        dd          g d           |                     t          j        dd          g d           dg dfdg dfdg dfd g d!ffD ]\\  }}|                     |"          5  |                     t          j        |d          |           d d d            n# 1 swxY w Y   ]dg d#fd$g d%fd&g d'fd(g d)ffD ]\\  }}|                     |"          5  |                     t          j        |d          |           d d d            n# 1 swxY w Y   ]d S )*N:a:b::c:)r   rs   rP   r   ru   :+)r   rs   rP   ru   (:+))r   r  rs   r  rP   ::ru   s   :a:b::c   :)r   rK      br      c   :+)r   rK   r	  r
     (:+))r   r  rK   r  r	     ::r
  )u   àßçu   абвu   𝒜𝒞𝒵r  r   z(?::+)z(:)+)r   r  rs   r  rP   r  ru   z([b:]+))r   r  rs   z:b::ru   z(b)|(:+))r   Nr  rs   Nr  r   rP   Nr   Nr  ru   z(?:b)|(?::+))r   rs   r   r   ru   z:*)r   r   rs   r   rP   r   ru   r   z(?::*)(:*))r   r  r   r   rs   r  r   r   rP   r  r   r   ru   r   r   z(:)*)r   r  r   Nrs   r  r   NrP   r  r   Nru   Nr   )sep)	r   r  rs   r  rP   r  r  ru   r   \b)r  rs   r  rP   r  ru   r   z(?=:))r   z:az:br  z:cz(?<=:))r  a:zb:r  ru   )	r   r6   r:   splitr#   rL   r   r5   r=   )r   rG   rs   rP   ru   r  expecteds          r   test_re_splitzReTests.test_re_splitt  s&   9- 	G 	GF!!"(3"7"7"9"9"9; ; ;!!"(4"8"8"5"5"57 7 7!!"(66":":"E"E"EG G G G!1Z==)J2G2G!*--/ 	N 	NF!!"(4"8"8">">">@ @ @!!"(5&"9"9"9"9"9; ; ;!!"(7F";";"L"L"LN N N N: 	< 	<GAq!!%&QQ11-FRXc622RAr14EFFFRXdF33b!Q]CCCRXff55 #q#q$:< < < < 	(I668K8K8KLLL&)44;;;	= 	= 	=)Y77444	6 	6 	6*i88+ + +	, 	, 	, 	.)<<///	1 	1 	1 6667:::;XXXY___`	
 	J 	JMC #&& J J%%bhsI&>&>IIIJ J J J J J J J J J J J J J J <<<=777822233334	
 	J 	JMC #&& J J%%bhsI&>&>IIIJ J J J J J J J J J J J J J J	J 	Js$   .*L$$L(	+L(	!*NN	N	c                     |                      t          j        ddd          g d           |                      t          j        ddd          g d           |                      t          j        ddd          g d           |                      t          j        ddd          g d	           |                      t          j        d
dd          g d	           |                      t          j        ddd          g d           d S )Nr  r  rm   )r   rs   b::c)maxsplitza:b:c:d)rs   rP   zc:dz(:))r   r  rs   r  r  r  r  )r   r  r   r   za:b::c)r5   r:   r  rh   s    r   test_qualified_re_splitzReTests.test_qualified_re_split  s/   #y!446G6G6GHHH#y1===?P?P?PQQQ#y1===?P?P?PQQQ%Q???444	6 	6 	6&)a@@@444	6 	6 	6&)a@@@444	6 	6 	6 	6 	6r   c           
      H   |                      t          j        dd          g            dt          d          fD ]}|                     t          j        d|          g d           |                     t          j        d|          g d           |                     t          j        d|          g d           dt          d          t          d          t          d          fD ]}|                     t          j        d	|          g d
           |                     t          j        d|          g d
           |                     t          j        d|          g d           dD ]}|dz  }|dz  }d|d|d|d}|                      t          j        d|z  |          |||g           |                      t          j        d|z  |          |||g           |                      t          j        d|d|d|          |df||f||fg           d S )Nr  ro   
a:b::c:::dr  r  z:::r  z(:)(:*)))r  r   )r  r  )r  r  s
   a:b::c:::dr  )r  r  s   :::r  s   (:)(:*)))r  r   )r  r  )r  r  r   rm   r^   rs   rP   ru   dz%s+z(%s+)(z)(z*)r   )r5   r:   rU   r   r6   r#   rL   r   )r   rG   r1   r   r`   s        r   test_re_findallzReTests.test_re_findall  s   D%00"555"AlOO3 	H 	HF!!"*T6":":"4"4"46 6 6!!"*VV"<"<"4"4"46 6 6!!"*Y"?"?"F"F"FH H H H$a&6&6	-8P8P!-002 	N 	NF!!"*UF";";"7"7"79 9 9!!"*Wf"="="7"7"79 9 9!!"*Z"@"@"L"L"LN N N N1 	9 	9AQBa%CC%&QQCCC0FRZ	6::QCLIIIRZ!V<<q"clKKKRZZqqq!!!(<fEE "g1v2w79 9 9 9	9 	9r   c                 \    |                      t          j        dd          g d           d S )Nz(a|(b))aba)rs   r   )rP   rP   r!  r5   r:   rU   rh   s    r   test_bug_117612zReTests.test_bug_117612  s;    J66999	; 	; 	; 	; 	;r   c                    dt          d          fD ].}|                     t          j        d|                                          d           |                     t          j        d|                                          d           |                     t          j        d|                              d          d           |                     t          j        d|                              d          d           |                     t          j        d|                              dd          d           0dt          d          t          d          t          d          fD ].}|                     t          j        d|                                          d           |                     t          j        d	|                                          d
           |                     t          j        d	|                              d          d           |                     t          j        d	|                              d          d           |                     t          j        d	|                              dd          d           0dD ]=}|                     t          j        ||                                          d           |                     t          j        d|z  |                                          |f           |                     t          j        d|z  |                              d          |           |                     t          j        d|z  |                              d          |           |                     t          j        d|z  |                              dd          ||f           ?t          j	        d          }|                     |                    d                                          d           |                     |                    d                                          d           |                     |                    d                                          d           |                     |                    d                                          d           |                     |                    d                              d          d           t          j	        d          }|                     |                    d                              ddd          d           |                     |                    d                              ddd          d           |                     |                    d                              ddd          d            d S )!Nrs   r   (a)rs   r   r]   rs   rs   rK   s   (a))rK   )rK   rK   r   z(%s)z((a)|(b))(c)?)rs   rs   NNrP   )rP   NrP   Nac)rs   rs   Nru   bc)rP   NrP   ru   r   )rP   r   rP   ru   !(?:(?P<a1>a)|(?P<b2>b))(?P<c3>c)?rm   r^   rs   NNa1b2c3)NrP   N)rs   Nru   )
r   r5   r:   rg   groupsrz   r#   rL   r   r<   )r   rG   rs   r   s       r   test_re_matchzReTests.test_re_match  s   1S66k 	N 	NFRXc62299;;R@@@RXeV44;;==vFFFRXeV44::1==sCCCRXeV44::1==sCCCRXeV44::1a@@*MMMMAdGGYt__j6F6FF 	Q 	QFRXdF33::<<bAAARXff55<<>>HHHRXff55;;A>>EEERXff55;;A>>EEERXff55;;AqAA<PPPP1 	J 	JARXa^^2244b999RXfqj!44;;==tDDDRXfqj!44::1==qAAARXfqj!44::1==qAAARXfqj!44::1a@@1a&IIIIj))3..002HIII3..002HIII4//113HIII4//113HIII4//335HIIIj<==3--aA668IJJJ3--dD$??*	, 	, 	,4..q$::<LMMMMMr   c                     G d d          }t          j        dd          }|                     |                                d           |                     |                    d          d           |                     |                    d          d           |                     |                     |d                    d           |                     t
          |j        d           |                     t
          |j        d	           |                     t
          |j        dd
z             |                     t
          |j         |dd
z                       |                     t
          |j        d           |                     |                    dd          d           |                     |                     |d           |d                    d           d S )Nc                       e Zd Zd Zd ZdS )!ReTests.test_group.<locals>.Indexc                     || _         d S r   value)r   r6  s     r   __init__z*ReTests.test_group.<locals>.Index.__init__  s    "


r   c                     | j         S r   r5  rh   s    r   	__index__z+ReTests.test_group.<locals>.Index.__index__  s
    z!r   N)r   r   r   r7  r9  r   r   r   Indexr3    s2        # # #" " " " "r   r:  z(a)(b)rk   r   r]   rs   r^     r1   rm   rP   rs   )r:   rg   r5   rz   r9   r   )r   r:  r   s      r   
test_groupzReTests.test_group  s   	" 	" 	" 	" 	" 	" 	" 	" HXt$$D)))T***S)))q**C000*agr222*agq111*agq$w777*aguuQW~~>>>*ags333A
333q558844jAAAAAr   c                 :   t          j        d          }|                    d          }|                     |d         d           |                     |d         d            |                     |d         d            |                     d                    |          d           |                     |d         d           |                     |d	         d           |                     |d
         d            |                     |d         d            |                     t          d          5  |d          d d d            n# 1 swxY w Y   |                     t          d          5  |d          d d d            n# 1 swxY w Y   |                     t          d          5  |d          d d d            n# 1 swxY w Y   |                     t          d          5  |d          d d d            n# 1 swxY w Y   |                     t          d          5  |d          d d d            n# 1 swxY w Y   |                     t          d          5  |d          d d d            n# 1 swxY w Y   |                     t          d          5  d                    |           d d d            n# 1 swxY w Y   |                    d          }|                     |d         d           |                     |d         d            |                     |d         d           |                     d                    |          d           |                     |d         d           |                     |d	         d           |                     |d
         d            |                     |d         d           |                     t                    5  d	|d<   d d d            n# 1 swxY w Y   |                     t          t          |           d S )Nr*  rs   r,  r-  r.  za1={a1} b2={b2} c3={c3}za1=a b2=None c3=Noner   r]   rm   r^   zno such groupr   r;  r   rt   r   za1={a2}r(  ru   za1=a b2=None c3=c)
r:   r<   rg   r5   
format_mapr   r   r9   	TypeErrorlen)r   r   r   s      r   test_match_getitemzReTests.test_match_getitem  s   j<==IIcNN4#&&&4$'''4$'''2==a@@BXYYY1s###1s###1t$$$1t$$$##J@@ 	 	cFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##J@@ 	 	bEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##J@@ 	 	aDD	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##J@@ 	 	dGG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##J@@ 	 	dGG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##J@@ 	 	fII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##J@@ 	$ 	$  ###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ IIdOO4#&&&4$'''4#&&&2==a@@BUVVV1t$$$1s###1t$$$1s### y)) 	 	AaD	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	)S!,,,,,s   2	EEE-	FF	F(	F==GG#	G88G<?G<	H33H7:H7	I..I25I2J66J:=J:O//O36O3c                 `	   |                      t          j        dd                                          d           dt	          d          fD ]=}|                      t          j        d|                                          d           >dt          d          t          d          t          d          fD ]=}|                      t          j        d|                                          d           >dD ]M\  }}|d	||z   }|                      t          j        |||z                                             d           N|                      t          j        d
d                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j	        d                              ddd                                          d           |                      t          j	        d
                              ddd                                          d           |                      t          j	        d                              ddd                                          d           d S ) Nrs   rt   rk   za|abrl   s   abs   a|ab)u   àßu   абu   𝒜𝒞r   z.*?$ro   rb   z.*?za.*?babbaxxbr   r   rc   zabc$zabc
zabc\Zz(?m)abc$z	ab(?=c)cdabcdz
ab(?<=b)cdz
(?=a|ab)abr)  r]   r^   r?   endposr\   )
r5   r:   	fullmatchre   r   r#   rL   r   rf   r<   )r   rG   rs   rP   rs        r   test_re_fullmatchzReTests.test_re_fullmatch4  s   dC005577@@@AdGGm 	K 	KFR\'6::??AA6JJJJQuXXy'7'7E9J9JJ 	L 	LFR\(F;;@@BBFKKKKF 	D 	DDAqAAq1uu%AR\!QU3388::FCCCCgu55::<<fEEEfe4499;;VDDDh55::<<fEEEh66;;==vFFFh77<<>>GGG",ud33444",w88999",x99:::",{G<<===lF;;@@BBFKKKmV<<AACCVLLLmT::??AA6JJJJu''Aa'@@EEGG	Q 	Q 	QJw))&a)BBGGII6	S 	S 	SJv((Qq(AAFFHH&	R 	R 	R 	R 	Rr   c                    |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                     t          j        dd                     |                     t          j        dd                     |                      t          j        dd	                                          d
           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           t          j        d          }|                      |                    d                                          d           |                      |                    d                                          d           |                     |                    d                     |                     |                    d                     d                    d t          dd          D                       }d|z  }|                      t          j        |d                                          d           d S )Nz^(\()?([^()]+)(?(1)\))$r%  )r  rs   rs   Nrs   za)z(az^(?:(a)|c)((?(1)b|d))$rk   rs   rP   cd)Nr  z^(?:(a)|c)((?(1)|d))$r!  z(?P<g1>a)(?P<g2>b)?((?(g2)c|d))ro   rs   rP   ru   ad)rs   Nr  abdr(  r   c              3   $   K   | ]}d ||fz  V  dS r   r   r   s     r   r   z2ReTests.test_re_groupref_exists.<locals>.<genexpr>l  r   r   r]   r   z(?:%s)(?(200)z)r   r   )	r5   r:   rg   r/  rf   r<   r   r   re   )r   pr   s      r   test_re_groupref_existszReTests.test_re_groupref_existsR  s   "<eDDKKMM#	% 	% 	%"<cBBIIKK$	& 	& 	&"(#=tDDEEE"(#=tDDEEE":DAAHHJJ#	% 	% 	%";TBBIIKK$	& 	& 	&":DAAHHJJ$	& 	& 	&":C@@GGII"	$ 	$ 	$ J899..00(	* 	* 	*--//)	+ 	+ 	+!''%..)))!''$--((( hhKKq'9J9JKKKKK#%#w//4466?????r   c                 J   |                      ddd           |                      ddd           |                     t          d          5 }t          j        d           d d d            n# 1 swxY w Y   |                     |j        t                     |                     t          d	          5  t          j        d
           d d d            n# 1 swxY w Y   |                     t          d          5  t          j        d           d d d            n# 1 swxY w Y   |                      ddd           |                      ddd           |                     t          d          5  t          j        d           d d d            n# 1 swxY w Y   |                      ddd           |                      ddd           |                      ddd           |                      ddd           |                      ddd           |                      ddd           d S )Nz(?P<a>)(?(0)a|b)zbad group numberr   z()(?(-1)a|b)r   r   z/bad character in group name '\+1' at position 5z()(?(+1)a|b)z0bad character in group name '1_0' at position 23z()()()()()()()()()()(?(1_0)a|b)z/bad character in group name ' 1 ' at position 5z()(?( 1 )a|b)u   ()(?(㊀)a|b)r   u   ()(?(¹)a|b)r   u/   bad character in group name '१' at position 5u   ()(?(१)a|b)z()(?(1r   z()(?(1)a"missing ), unterminated subpatternrm   z
()(?(1)a|bz()(?(1)a|b|cz/conditional backref with more than two branchesz()(?(1)a|b|c)z	()(?(2)a)r   r   r   s     r   test_re_groupref_exists_errorsz&ReTests.test_re_groupref_exists_errorsp  s   24FKKKA1	F 	F 	F""#5$45 5 	(89J'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	X...""#5$56 6 	2 	2 J0111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 ""#5$45 5 	) 	) J'(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	/BA	G 	G 	GA1	F 	F 	F""#5$45 5 	) 	) J'(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	y=q	B 	B 	B{CQ	H 	H 	H}CQ	H 	H 	H ./1	3 	3 	3 	/ ./1	3 	3 	3 	|:A	? 	? 	? 	? 	?sH   
A++A/2A/1CCC8DD D-FFFc                     t          d          D ]G}|                     |          5  t          j        d|z             d d d            n# 1 swxY w Y   Hd S )N   )codez()(?(1)\x%02x?))r   r=   r:   r<   r   r   s     r   &test_re_groupref_exists_validation_bugz.ReTests.test_re_groupref_exists_validation_bug  s    s 	3 	3A1%% 3 3
-12223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	3 	3s   AA	A	c                     ddl m} |                     dd|z  dd|z  d           |                     d|z  d|z  d	           d S )
Nr   )	MAXGROUPSz()z\g<%s>r   zinvalid group reference %dr^   z(?P<a>)(?(%d))r   )re._constantsrb  rH   rC   )r   rb  s     r   test_re_groupref_overflowz!ReTests.test_re_groupref_overflow  s}    ++++++i)&;T <y H!	M 	M 	M09<;iG	M 	M 	M 	M 	Mr   c                    |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                     t          j        dd                     |                     t          j        dd                     |                      t          j        d	d
                                          d           |                      t          j        dd                                          d           |                     ddd           d S )Nz^(\|)?([^()]+)\1$z|a|)r   rs   z^(\|)?([^()]+)\1?$rs   rP  za|z|az^(?:(a)|c)(\1)$aar'  z^(?:(a)|c)(\1)?$ru   NNz(abc\1)r   r   )r5   r:   rg   r/  rf   rC   rh   s    r   test_re_grouprefzReTests.test_re_groupref  s=   "6>>EEGG#	% 	% 	%"7==DDFF$	& 	& 	&"(#7>>???"(#7>>???"4d;;BBDD#	% 	% 	%"5s;;BBDD%	' 	' 	' 	z+JANNNNNr   c                     |                      t          j        dd                                          ddd           d S )N#(?P<first>first) (?P<second>second)first secondfirstsecond)rl  rm  )r5   r:   rg   	groupdictrh   s    r   test_groupdictzReTests.test_groupdict  sL    "G"02 22;)++")H==	? 	? 	? 	? 	?r   c                     |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           d S )	Nrj  rk  z\2 \1 \g<second> \g<first>zsecond first second firstz#(?P<first>first)|(?P<second>second)rl  z\2 \g<second> )r5   r:   rg   expandrh   s    r   test_expandzReTests.test_expand  s    "G"02 2#)6*G#H#H4	6 	6 	6 	"G")+ +#)6*:#;#;	 	 	 	 	r   c                 	   |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                     t          j        dd                              d          d           |                     t          j        d	d                              d          d           |                     t          j        d
d                              d          d           |                     t          j        dd                              d          d           |                     t          j        dd                              d          d           |                     t          j        dd                              d          d           |                     t          j        dd                              d          d           |                     t          j        dd                              d          d           |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                      t          j        dd                     |                     t          j        dd                     |                     ddd            d S )!Nz	^(\w){1}$ro   z
^(\w){1}?$z^(\w){1,2}$z^(\w){1,2}?$z	^(\w){3}$r]   ru   z^(\w){1,3}$z^(\w){1,4}$z^(\w){3,4}?$z
^(\w){3}?$z^(\w){1,3}?$z^(\w){1,4}?$z^x{1}$r`   z^x{1}?$z^x{1,2}$z	^x{1,2}?$z^x{3}$z^x{1,3}$z^x{3,3}$z^x{1,4}$z	^x{3,4}?$z^x{3}?$z	^x{1,3}?$z	^x{1,4}?$z^x{}$x{}zx{2,1}z"min repeat greater than max repeatrm   )rf   r:   rg   r5   rz   
assertTruerC   rh   s    r   test_repeat_minmaxzReTests.test_repeat_minmax  s   "(<77888"(=%88999"(>599:::"(?E::;;;,66<<Q??EEE.%88>>qAA3GGG.%88>>qAA3GGG/599??BBCHHH-77==a@@#FFF/599??BBCHHH/599??BBCHHH/599??BBCHHH"(9e44555"(:u55666"(;66777"(<77888E22333e44555e44555e44555u55666U33444u55666u55666u55666"(8U33444511222yCQ	H 	H 	H 	H 	Hr   c                 >   |                      t          j        d          j        d           |                      t          j        d          j        t          j        t          j        z             |                      t          j        d          j        d           |                      t          j        d          j        i            |                      t          j        d          j        ddd           |                      t          j	        dd          j
        d           |                      t          j	        dd          j        d           |                      t          j	        dd          j        d           |                      t          j	        dd          j        d	           |                     t          j	        dd          j                   t          j        d          }|                      t          |j                  d
dg           |                      |j        d         d           |                     t"                    5  d|j        d<   d d d            n# 1 swxY w Y   |                      |j        d         d           d S )Nz
(?i)(a)(b)rm   z(?i)(?P<first>a)(?P<other>b)r]   )rl  otherr%  rs   r   )rt   rt   rl  ry  )r5   r:   r<   r8   flagsr   Ur/  
groupindexrg   r?   rK  rG   regsrv  sortedr9   rB  )r   rW  s     r   test_getattrzReTests.test_getattr  sm   L119<HHHL117EEEL118!<<<L11<bAAA$BCCN#$q11	3 	3 	3 	%--11555%--4a888%--4c:::%--24DEEE,,/000 J677--/ABBBg.222y)) 	& 	&$%AL!	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&g.22222s   I11I58I5c                 .	   |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d	          d
           |                      t          j        dd
t          j                                      d	          d
           |                     t          j        ddt          j                             |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d	          d           |                      t          j        ddt          j                                      d	          d           |                     t          j        ddt          j                             |                      t          j        dd                              d	          d           |                      t          j        dd                              d	          d           |                      t          j        ddt          j                                      d	          d           |                      t          j        ddt          j                                      d	          d           d S )Nz\b(b.)\bzabcd abc bcd bxr]   bxz\B(b.)\Bzabc bcd bc abxdz^abc$z
abc
r   ro   z	^\Aabc\Z$s   \b(b.)\bs   abcd abc bcd bxs   bxs   \B(b.)\Bs   abc bcd bc abxds   ^abc$s   
abc
   abcs	   ^\Aabc\Z$z\d\D\w\W\s\Sz1aa! as   \d\D\w\W\s\Ss   1aa! a)r5   r:   rd   rz   ASCIIMrf   LOCALErh   s    r   test_special_escapeszReTests.test_special_escapes  s   ;#46 66;eAhh	F 	F 	F;#46 66;eAhh	F 	F 	F;#4bh@ @@Ea$	P 	P 	P;#4bh@ @@Ea$	P 	P 	P8Y==CCAFFNNN<==CCAFFNNN")L)RTBBCCC<#57 77<uQxx	H 	H 	H<#57 77<uQxx	H 	H 	H<#5ryB BBG%((E	S 	S 	S<#5ryB BBG%((E	S 	S 	S9j"$??EEaHH&QQQ=&"$??EEaHH&QQQ")M:rtDDEEE?#+- --2U1XXx	A 	A 	A#3#,. ..3eAhh		C 	C 	C?#+RX7 77<uQxx	K 	K 	K#3#,bi9 99>q9	N 	N 	N 	N 	Nr   c                 h   |                      ddd           |                     t          j        dd                                          d           |                     t          j        dd                     |                     t          j        dd                                          d           |                     t          j        dd	                                          d	           |                     t          j        dd
                     |                     t          j        dd                                          d           |                     t          j        dd                     |                     t          j        dd                                          d           |                     t          j        dd                     t          j                     dD ]]}|                     |          5  |                     t          j	        t          j
        d|z             d d d            n# 1 swxY w Y   ^dD ]]}|                     |          5  |                     t          j	        t          j
        d|z             d d d            n# 1 swxY w Y   ^d S )Nr   zbad escape (end of pattern)r   z\(r  )r   z[\]]][z[a\-c]-rP   z[\^a]+za^!ceghijklmopqyzCEFGHIJKLMNOPQRTVXYz\%c$ceghijklmopqyzABCEFGHIJKLMNOPQRTVXYZz[\%c])rC   r5   r:   rg   rz   rf   purger=   r9   r;   r<   )r   ru   s     r   test_other_escapeszReTests.test_other_escapes  s   t%BAFFF%--3355s;;;"(5#..///%..4466==='3//5577==="(7C00111)S1177993???"(9c22333)T2288::DAAA"(9c22333



4 	D 	DAa D D!!"(BJ
CCCD D D D D D D D D D D D D D D7 	F 	FAa F F!!"(BJ1EEEF F F F F F F F F F F F F F F	F 	Fs$   /II
	I
	+/J&&J*	-J*	c                 D   |                      t          j        dd                     |                      t          j        dd                     |                     t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        d	d
                     |                     t          j        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 ))Nz\N{LESS-THAN SIGN}<z\N{less-than sign}>z	\N{SNAKE}u   🐍zW\N{ARABIC LIGATURE UIGHUR KIRGHIZ YEH WITH HAMZA ABOVE WITH ALEF MAKSURA ISOLATED FORM}u   ﯹz*[\N{LESS-THAN SIGN}-\N{GREATER-THAN SIGN}]=;z\Nz	missing {rm   z[\N]r^   z\N{zmissing character namez[\N{r   z\N{}z[\N{}]z\NSNAKE}z
[\NSNAKE}]z\N{SNAKEzmissing }, unterminated namez
[\N{SNAKE]z[\N{SNAKE]}z!undefined character name 'SNAKE]'r]   z\N{SPAM}zundefined character name 'SPAM'r   z
[\N{SPAM}]z\N{KEYCAP NUMBER SIGN}z-undefined character name 'KEYCAP NUMBER SIGN'z[\N{KEYCAP NUMBER SIGN}]s   \N{LESS-THAN SIGN}zbad escape \Ns   [\N{LESS-THAN SIGN}])rv  r:   rg   rf   rC   rh   s    r   test_named_unicode_escapesz"ReTests.test_named_unicode_escapes.  s   !6<<===!6<<==="(#8#>>???|<<=== "Q!)+ + 	, 	, 	, 	!N!$& & 	' 	' 	'"(#P#&( ( 	) 	) 	) 	uk1555wQ777v'?CCCw(@!DDDw(@!DDDy*BAFFF{K;;;}k1==={=q	B 	B 	B}=q	B 	B 	B~BA	G 	G 	G{@!	E 	E 	E}@!	E 	E 	E8KQ	P 	P 	P:KQ	P 	P 	P57GKKK79I1MMMMMr   c                 *   |                      t          j        dd                              d          d           |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                      t          t          j	        dd                    d           |                      t          t          j	        dd                    d	           |                      t          t          j	        dd
                    d	           |                      t          t          j	        dd                    d	           |                      t          t          j	        dd
                    d           d S )Nz	\b(abc)\bro   r]   r  \Br   rs   rm   r   rq  z   )
r5   r:   rd   rz   rv  rg   assertFalserf   rC  rU   rh   s    r   test_string_boundarieszReTests.test_string_boundariesV  s   <77==a@@	  	  	  	..///	%//000%//000 	")E2../// 	")E2../// 	RZs3344a888RZs3344a888RZs3344a888RZu5566:::RZs3344a88888r   c                 h   |                      t          j        dd                              d          d           dd                    t          t          t          ddd                              z  }|                      t          j        |d	                                          d	           d S )
Nu
   ([∢∣])u   ∢r]   z[%s]r   r]        u   ！)r5   r:   rg   rz   r   mapr   r   r   rM  s     r   test_bigcharsetzReTests.test_bigcharsetp  s    "4"*, ,,1E!HHh	@ 	@ 	@RWWSeC&<&<==>>>!X..4466AAAAAr   c                 "   t          j        d                    d t          d          D                                 }|                     |                    d                     |                     |                    d                     d S )Nr   c              3       K   | ]	}d |z  V  
dS )z%dNr   )r   r1   s     r   r   z,ReTests.test_big_codesize.<locals>.<genexpr>x  s&       > >Aa > > > > > >r   '  10009999)r:   r<   r   r   rv  rg   r  s     r   test_big_codesizezReTests.test_big_codesizev  sp    Jsxx > >u > > >??@@((((((((r   c                 "   |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d          d           d S )Nza.bza
br   za.*bza

b)r5   r:   rg   DOTALLrz   rh   s    r   test_anyallzReTests.test_anyall|  s    %;;AA!DD	! 	! 	!&(BI>>DDQGG!	# 	# 	# 	# 	#r   c                 N   |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           |                      t          j        d	d
                              d          d           |                      t          j        dd                              d          d           |                      t          j        dd
                              d          d           |                      t          j        dd
                              d          d           |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     d S )Nz(a(?=\s[^a]))a br]   rs   z(a(?=\s[^a]*))z(a(?=\s[abc]))z(a(?=\s[abc]*))a bcz(a)(?=\s\1)a az(a)(?=\s\1*)a aaz(a)(?=\s(abc|a))z(a(?!\s[^a]))z(a(?!\s[abc]))za dz(a)(?!\s\1)z(a)(?!\s(abc|a))z(a)b(?=\1)ar   z(a)b(?=\1)cabacz(?:(a)|(x))b(?=(?(2)x|c))cro   z(?:(a)|(x))b(?=(?(2)c|x))cz(?:(a)|(x))b(?=(?(1)b|x))cz(?:(a)|(x))b(?=(?(1)c|x))cz(a)b(?=(?(2)x|c))(c)z(a)b(?=(?(2)b|x))(c)z(a)b(?=(?(1)c|x))(c))r5   r:   rg   rz   rv  rf   rh   s    r   test_lookaheadzReTests.test_lookahead  s^   "2E::@@CCSIII"3U;;AA!DDcJJJ"3U;;AA!DDcJJJ"4f==CCAFFLLL.%88>>qAA3GGG/6::@@CCSIII"5u==CCAFFLLL"2E::@@CCSIII"3U;;AA!DDcJJJ.%88>>qAA3GGG"5u==CCAFFLLL 	77888"(>6::;;;!>FFGGG"(#@%HHIII!>FFGGG"(#@%HHIII!>FFGGG!8%@@AAA"(#:EBBCCC!8%@@AAAAAr   c                 d   |                      t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                     t          j        dd	                     |                     t          j        d
d                     |                      t          j        dd	                     |                     t          j        dd                     |                     t          j        dd                     |                      t          j        dd                     |                     t          j        dd                     |                      t          j        dd                     |                     t          j        t          j        d           |                     t          j        dd                     |                      t          j        dd                     |                     t          j        t          j        d           |                     t          j        t          j        d           |                     t          j        t          j        d           |                     t          j        t          j        d           d S )Nz	ab(?<=b)cro   z	ab(?<=c)cz	ab(?<!b)cz	ab(?<!c)cz(a)a(?<=\1)caacz(a)b(?<=\1)aabaaz(a)a(?<!\1)cz(a)b(?<!\1)az(?:(a)|(x))b(?<=(?(2)x|c))cz(?:(a)|(x))b(?<=(?(2)b|x))cz(?:(a)|(x))b(?<=(?(2)x|b))cz(?:(a)|(x))b(?<=(?(1)c|x))cz(?:(a)|(x))b(?<=(?(1)b|x))cz(a)b(?<=(?(2)b|x))(c)z(a)b(?<=(?(1)c|x))(c)z(a)b(?<=(?(1)b|x))(c)z(a)b(?<=(.)\2)(c)z(a)b(?<=(?P<a>.)(?P=a))(c)z(a)b(?<=(a)(?(2)b|x))(c)z(a)b(?<=(.)(?<=\2))(c))rv  r:   rg   rf   r9   r;   r<   rh   s    r   test_lookbehindzReTests.test_lookbehind  sr   u55666"(<77888"(<77888u55666%88999"(?F;;<<<"(?E::;;;&99:::"(#A5IIJJJ"(#A5IIJJJ!?GGHHH"(#A5IIJJJ!?GGHHH"(BJ0HIII"(#;UCCDDD!95AABBB"(BJ0DEEE"(BJ0MNNN"(BJ0KLLL"(BJ0IJJJJJr   c                    |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d          d           |                      t          j        d	d
t          j                                      d          d
           |                      t          j        ddt          j                                      d          d           |                      t          j        dd
t          j                                      d          d
           |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d          d           |                      t          j        ddt          j                                      d          d           |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        ddt          j                             |                     t          j        d dt          j                             |                     t          j        d dt          j                             |                     t          j        d!d"t          j                             |                     t          j        d#d$t          j                             d S )%Nro   ABCr   r  s   ABCz	(a\s[^a])r  r]   z
(a\s[^a]*)za bbz
(a\s[abc])z(a\s[abc]*)z	((a)\s\2)r  z
((a)\s\2*)r  z((a)\s(abc|a))z((a)\s(abc|a)*)K   Kkz\u212ar      ſrV   z\u017fz\u0412   в   ᲀz\u0432   Вz\u1c80z\ufb05   ﬆz\ufb06   ﬅ)r5   r:   rg   r   rz   rv  rh   s    r   test_ignore_casezReTests.test_ignore_case  s:   %55;;A>>FFF&&"$77==a@@&III,rt<<BB1EEuMMM->>DDQGGPPP-==CCAFFNNN.&"$??EEaHH&QQQ,rt<<BB1EEuMMM->>DDQGGPPP"3UBDAAGGJJERRR"4fbdCCII!LLfUUU 	x66777x66777C66777C66777 	x66777x66777C66777C66777 	Hbd;;<<<Hbd;;<<<Hbd;;<<<Hbd;;<<<Hbd;;<<<Hbd;;<<< 	Hbd;;<<<Hbd;;<<<<<r   c                 	   |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        d	d
t          j                             |                      t          j        dd
t          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             d S )Nz[19A]r   z[19a]rs   s   [19A]   As   [19a]rK   z[19K]r  z[19k]z
[19\u212a]r  r  z[19S]r  z[19s]z
[19\u017f]r   rV   z
[19\u0412]r  r  z
[19\u0432]r  z
[19\u1c80]z
[19\ufb05]r  z
[19\ufb06]r  )rv  r:   rg   r   rh   s    r   test_ignore_case_setzReTests.test_ignore_case_set  s@   355666355666355666355666D"$77888D"$77888D"$77888D"$77888 	8RT::;;;8RT::;;;RT::;;;RT::;;; 	8RT::;;;8RT::;;;RT::;;;RT::;;; 	"$??@@@"$??@@@"$??@@@"$??@@@"$??@@@"$??@@@ 	"$??@@@"$??@@@@@r   c                    |                      t          j        ddt          j                             |                     t          j        ddt          j                             |                      t          j        ddt          j                             |                     t          j        ddt          j                             |                      t          j        ddt          j                             |                     t          j        dd	t          j                             |                      t          j        d
d	t          j                             |                     t          j        d
dt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        dd t          j                             |                      t          j        dd!t          j                             |                      t          j        d"d#t          j                             |                      t          j        d"d!t          j                             |                      t          j        d$d#t          j                             |                      t          j        d$d t          j                             |                      t          j        d%d&t          j                             |                      t          j        d'd(t          j                             d S ))Nz[9-a]_z[9-A]s   [9-a]   _s   [9-A]z[\xc0-\xde]   ×   ÷z[\xe0-\xfe]z[\u0430-\u045f]u   ѐu   Ѐz[\u0400-\u042f]z[\U00010428-\U0001044f]u   𐐨u   𐐀z[\U00010400-\U00010427]z[J-M]r  z[j-m]z[\u2129-\u212b]r  r  z[R-T]r  z[r-t]z[\u017e-\u0180]r   rV   z[\u0411-\u0413]r  r  z[\u0431-\u0433]r  z[\u1c80-\u1c82]z[\ufb04-\ufb05]r  z[\ufb06-\ufb07]r  )rv  r:   rg   r   rf   rh   s    r   test_ignore_case_rangezReTests.test_ignore_case_range  sl   355666"(8S"$77888D"$77888"(9dBD99:::>>???"(>624@@AAA>>???"(>624@@AAA!3XrtDDEEE!3XrtDDEEE!3XrtDDEEE!3XrtDDEEE!;\24PPQQQ!;\24PPQQQ!;\24PPQQQ!;\24PPQQQ 	8RT::;;;8RT::;;;!3S"$??@@@!3S"$??@@@ 	8RT::;;;8RT::;;;!3S"$??@@@!3S"$??@@@ 	!3XrtDDEEE!3XrtDDEEE!3XrtDDEEE!3XrtDDEEE!3XrtDDEEE!3XrtDDEEE 	!3XrtDDEEE!3XrtDDEEEEEr   c                 ~    |                      t          j        dd                              d          d           d S )Nz(\s)rq  r]   r5   r:   rg   rz   rh   s    r   test_categoryzReTests.test_category5  s8    '3//55a88#>>>>>r   c                     |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           d S )Nz\s([^a]) br]   rP   z	\s([^a]*)z bbbbr5   r:   rd   rz   rh   s    r   test_not_literalzReTests.test_not_literal8  sh    ;55;;A>>DDD<77==a@@$GGGGGr   c                    t          t          d                                                    }|                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     |                     t          j        d|          t          d                     |                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     |                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d	                     |                     t                    5  t          j        d
          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     |                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     |                     t          j        d|          t          d                     |                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     |                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     |                     t          j        d|          t          d                     |                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     |                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     |                     t          j        d|          t          d                     |                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     |                     t                    5  t          j        d          }d d d            n# 1 swxY w Y   |                     |                    |          t          d                     d S )N   z[0-9--1]z-./0123456789z[--1]z-./01z[%--1]z
%&'()*+,-1z[%--]z	%&'()*+,-z[0-9&&1]z&0123456789z[\d&&1]z[&&1]z&1z[0-9||a]z0123456789a|z[\d||a]z[||1]z1|z[0-9~~1]z0123456789~z[\d~~1]z[~~1]z1~z[[0-9]|]z0123456789[]z[[:digit:]|]z:[]dgit)
bytesr   decodeassertWarnsFutureWarningr:   r<   r5   rU   r+   r   rV   rW  s      r   test_possible_set_operationsz$ReTests.test_possible_set_operations<  s   %**$$&&m,, 	( 	(
;''A	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(1tO'<'<===Ha00$w--@@@m,, 	& 	&
9%%A	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&1tL'9'9:::m,, 	% 	%
8$$A	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%1tK'8'8999m,, 	( 	(
;''A	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(1tM':':;;;m,, 	' 	'
:&&A	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'1tM':':;;;Ha00$t**===m,, 	( 	(
;''A	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(1tN';';<<<m,, 	' 	'
:&&A	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'1tN';';<<<Ha00$t**===m,, 	( 	(
;''A	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(1tM':':;;;m,, 	' 	'
:&&A	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'1tM':':;;;Ha00$t**===m,, 	( 	(
;''A	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(1tN';';<<<m,, 	, 	,
?++A	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,1tI77777s   	A**A.1A.;DD #D 7FFF3HHH/JJJ!MM	MN>>OOQ00Q47Q4S,,S03S0=VV"%V"9XX!Xc                     |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           d S )Nz\s(b)r  r]   rP   za\sza r   r  rh   s    r   test_search_coveragezReTests.test_search_coveragei  sh    8T2288;;SAAA640066q994@@@@@r   c                 >   |||}dt          |          f}n||t          d           |||          }|                     |           |                     |                                |           |                     |                                |           d S )Nr   z@If match is not None, span should be specified (and vice versa).)rC  r   rv  r5   rz   re   )r   r8   textrg   re   matcherr   s          r   assertMatchzReTests.assertMatchm  s    =T\Es4yy>DD]dl 1 2 2 2GGT""E***4(((((r   z!"%',/:;<=>@_`c                    d                     d t          d          D                       }|D ]}|                     t          j        |          |           |                     dt          j        |          z   dz   |           |                     dt          j        |          z   |           |                     t          j        |          |           dD ]2}|                     t          j        |          d d         d	           3| j        }|                     t          j        |          |           d S )
Nr   c              3   4   K   | ]}t          |          V  d S r   )r   r   s     r   r   z)ReTests.test_re_escape.<locals>.<genexpr>~  s(      //qCFF//////r   r]  r  r  z(?x)z-.]{}r]   r   )r   r   r  r:   escaper5   LITERAL_CHARS)r   rW  ru   literal_charss       r   test_re_escapezReTests.test_re_escape}  s(   GG//E#JJ///// 	7 	7ARYq\\1---S29Q<</#5q999Vbill2A66661q))) 	5 	5ARYq\\"1"-t4444*=11=AAAAAr   c                    t          t          d                    }|D ]}t          |g          }|                     t          j        |          |           |                     dt          j        |          z   dz   |           |                     dt          j        |          z   |           |                     t          j        |          |           dD ]B}t          |g          }|                     t          j        |          d d         d           C| j                            d          }|                     t          j        |          |           d S )	Nr]     [   ]s   (?x)s   -.]{}r]      \ascii)r  r   r  r:   r  r5   r  encode)r   rW  r   rP   r  s        r   test_re_escape_byteszReTests.test_re_escape_bytes  s=   %** 	8 	8Aqc

ARYq\\1---TBIaLL047;;;Wry||3Q77771q))) 	6 	6Aqc

ARYq\\"1"-u5555*11'::=11=AAAAAr   c                     d}t          j        |          }|                     ||           |                     ||           |                     dt          j        d          z  |ddt           j                   d S )Nu   xxx☠☠☠xxxz.%s+.   ☠u   x☠☠☠x)rm   r   )r:   r  r5   r  rd   )r   rV   	s_escapeds      r   test_re_escape_non_asciiz ReTests.test_re_escape_non_ascii  s    &IaLL	A&&&A&&&29X#6#66/	D 	D 	D 	D 	Dr   c                 j   d                     d          }t          j        |          }|                     ||           |                     ||           t          j        t          j        d                     d                    |          }|                     t          |          d           d S )Nu	   y☠y☠yzutf-8r  rm   )r  r:   r  r5   r  rU   rC  )r   rP   	b_escapedress       r   test_re_escape_non_ascii_bytesz&ReTests.test_re_escape_non_ascii_bytes  s    $$W--IaLL	A&&&A&&&j8??7#;#;<<a@@S1%%%%%r   c                    dd l }t          j        dt          j                  }t	          |j        dz             D ]C}|                    ||          }|                    |          }|                     ||           Dddlm	} d S )Nr   za(?:b|(c|e){1,2}?|d)+?(.)r]   )_compile)
pickler:   r<   UNICODEr   HIGHEST_PROTOCOLdumpsloadsr5   r  )r   r  oldpatprotopicklednewpatr  s          r   test_picklingzReTests.test_pickling  s    7DD62Q677 	- 	-Ell6511G\\'**FVV,,,,r   c                    dd l }t          j        d          }|                     |                     |          |           |                     |                    |          |           |                    d          }|                     |                     |          |           |                     |                    |          |           d S )Nr   z (?P<int>\d+)(?:\.(?P<frac>\d*))?z12.34)copyr:   r<   r-   deepcopyrg   )r   r  rW  r   s       r   test_copyingzReTests.test_copying  s    J:;;diillA&&&dmmA&&***GGGdiillA&&&dmmA&&*****r   c                    |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j        t          j	                   |                      t          j
        t          j                   d S r   )r5   r:   r   
IGNORECASELr  r  	MULTILINEr   r  r   VERBOSErh   s    r   test_constantszReTests.test_constants  s    r}---ry)))r|,,,ry)))rz*****r   c                    t           j        t           j        t           j        t           j        t           j        t           j        fD ]*}|                     t          j        d|                     +t           j        t           j        t           j        t           j        t           j        t           j	        fD ]*}|                     t          j        d|                     +d S )Nz	^pattern$s	   ^pattern$)
r:   r   r  r   r   r   r{  rv  r<   r  )r   flags     r   
test_flagszReTests.test_flags  s    T24rtRT248 	; 	;DOOBJ{D99::::T24rtRT248 	< 	<DOOBJ|T::;;;;	< 	<r   c           	      |   dD ]}|dk     r\|                      t          j        d|z  t          |                               |                      t          j        d|z  t          |          dz                        |                      t          j        d|z  t          |          dz                        |                      t          j        d|z  t          |                               |                      t          j        d	|z  t          |          dz                        |                      t          j        d
|z  t          |          dz                        |dk     r|                      t          j        d|z  t          |                               |                      t          j        d|z  t          |          dz                        |                      t          j        d|z  t          |          dz                        |                      t          j        d|z  t          |                               |                      t          j        d|z  t          |          dz                        |                      t          j        d|z  t          |          dz                        |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        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 ),Nr   r          @      r  r  r]    r  i r]  \%03o\%03o00\%03o88\x%02x\x%02x0\x%02xzzr  z\u%04xz\u%04x0z\u%04xzz\U%08xz\U%08x0z\U%08xzr   r   r   r   z\01r   z\018z8z\5670octal escape value \567 outside of range 0-0o377r   z\911invalid group reference 91r]   z\x1incomplete escape \x1z\x1zz\u123incomplete escape \u123z\u123zz	\U0001234incomplete escape \U0001234z
\U0001234zz
\U00110000bad escape \U00110000rv  r:   rg   r   rC   r_  s     r   test_sre_character_literalsz#ReTests.test_sre_character_literals  s   R 	B 	BA3wwAs1vv > >???QAs
 C CDDDQAs
 C CDDDQA ? ?@@@aQ D DEEEaQ D DEEE7{{QA ? ?@@@aQ D DEEEaQ D DEEEOOBHY]CFF;;<<<OOBHZ!^SVVCZ@@AAAOOBHZ!^SVVCZ@@AAAA//0001122200111'22333w 012	4 	4 	4 	w(DaHHHv'?CCCw(@!DDDx)CQGGGy*DaHHH|-KQOOO}.LaPPP}.FJJJJJr   c           	         dD ]&}|dk     r|                      t          j        d|z  t          |                               |                      t          j        d|z  t          |                               |                      t          j        d|z  t          |                               |                      t          j        d|z  t          |                               |                      t          j        d|z  t          |                               |                      t          j        d|z  t          |                               |                      t          j        d	|z  t          |                               |                      t          j        d
|z  t          |                               |dk     r|                      t          j        d|z  t          |                               |                      t          j        d|z  t          |                               |                      t          j        d|z  t          |                               |                      t          j        d|z  t          |                               |                      t          j        d|z  t          |          dz                        |                      t          j        d|z  t          |          dz                        (|                     ddd           |                     ddd           |                     ddd           |                     ddd           |                     ddd           |                     dd d           |                      t          j        d!d"                     d S )#Nr  r]  [\%o][\%o8][\%03o][\%03o0][\%03o8][\x%02x]	[\x%02x0]	[\x%02xz]r  z[\u%04x]z	[\u%04x0]z	[\u%04xz]z[\U%08x]z	[\U%08x0]r  z	[\U%08xz]r  z[\567]r  r]   z[\911]bad escape \9z[\x1z]r  z[\u123z]r   z[\U0001234z]r!  z[\U00110000]r"  z[\U0001d49c-\U0001d4b5]u   𝒞r#  r_  s     r   !test_sre_character_class_literalsz)ReTests.test_sre_character_class_literals  s-   R 	D 	DA3wwAs1vv > >???QA ? ?@@@aQ @ @AAAq#a&& A ABBBq#a&& A ABBBq#a&& A ABBB)93q66 B BCCC)93q66 B BCCC7{{q#a&& A ABBB)93q66 B BCCC)93q66 B BCCCOOBH[1_c!ff==>>>OOBH\A%5s1vvczBBCCCOOBH\A%5s1vvczBBCCCCy 012	4 	4 	4 	y*:A>>>y*BAFFF{,FJJJ0NPQRRR0H!LLL!;\JJKKKKKr   c           	      T   dD ]}|                      t          j        d|z                                  t	          |g                               |                      t          j        d|z                                  t	          |g          dz                        |                      t          j        d|z                                  t	          |g          dz                        |                      t          j        d|z                                  t	          |g                               |                      t          j        d|z                                  t	          |g          dz                        |                      t          j        d	|z                                  t	          |g          d
z                        |                     t          j        t          j        d           |                     t          j        t          j        d           |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                     ddd           |                     ddd           |                     ddd           |                     ddd           d S )Nr   r   r  r  r  r  r  r  r  r     0r     8r  r  r     zs   \u1234s
   \U00012345s   \0    s   \08s    8s   \01   s   \018s   8s   \567r  r   s   \911r  r]   s   \x1r  s   \x1z	rv  r:   rg   r  r  r9   r;   r<   rC   r_  s     r   test_sre_byte_literalszReTests.test_sre_byte_literals  s   2 	R 	RAOOBHhl%:%:%<%<eQCjjIIJJJOOBHi!m%;%;%=%=uaSzz$OOPPPOOBHi!m%;%;%=%=uaSzz$OOPPPOOBHi!m%;%;%=%=uaSzzJJKKKOOBHj1n%<%<%>%>qc

4PPQQQOOBHj1n%<%<%>%>qc

4PPQQQQ"(BJ
;;;"(BJ???11222(33444'22333844555x 012	4 	4 	4 	x)EqIIIw(@!DDDx)A1EEEEEr   c           	         dD ][}|                      t          j        d|z                                  t	          |g                               |                      t          j        d|z                                  t	          |g                               |                      t          j        d|z                                  t	          |g                               |                      t          j        d|z                                  t	          |g                               |                      t          j        d|z                                  t	          |g                               |                      t          j        d|z                                  t	          |g                               |                      t          j        d|z                                  t	          |g                               |                      t          j        d	|z                                  t	          |g                               ]|                     t          j        t          j        d
           |                     t          j        t          j        d           |                     ddd           |                     ddd           |                     ddd           d S )Nr1  r&  r'  r(  r)  r*  r+  r,  r-  s   [\u1234]s   [\U00012345]s   [\567]r  r]   s   [\911]r.  s   [\x1z]r  r7  r_  s     r   test_sre_byte_class_literalsz$ReTests.test_sre_byte_class_literals  s]   2 	O 	OAOOBHhl%:%:%<%<eQCjjIIJJJOOBHi!m%;%;%=%=uaSzzJJKKKOOBHj1n%<%<%>%>qc

KKLLLOOBHkAo%=%=%?%?sLLMMMOOBHkAo%=%=%?%?sLLMMMOOBHkAo%=%=%?%?sLLMMMOOBHlQ&6%>%>%@%@%**MMNNNOOBHlQ&6%>%>%@%@%**MMNNNN"(BJ==="(BJ0@AAAz 012	4 	4 	4 	z+;Q???z+CQGGGGGr   c                 H   |                      ddd           |                      ddd           |                      ddd           |                      ddd           |                      ddd	           |                      d
dd	           |                      ddd	           d S )Nr  zunterminated character setr   z[^z[az[a-z[\w-b]zbad character range \w-br]   z[a-\w]zbad character range a-\wz[b-a]zbad character range b-arC   rh   s    r   test_character_set_errorsz!ReTests.test_character_set_errors*  s    t%A1EEEu&BAFFFu&BAFFF 	v'CQGGGy*EqIIIy*EqIIIx)BAFFFFFr   c                 n   |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           |                      t          j        dd                              d          d           d S )Nz(a)|(b)rP   r]   r;  )r;  r;  )r5   r:   rg   startendre   rh   s    r   test_bug_113254zReTests.test_bug_1132545  s    *c2288;;R@@@*c2266q992>>>*c2277::HEEEEEr   c                    |                      t          j        dd          j                   |                     t          j        dd          j        d           |                     t          j        dd          j        d           |                     t          j        dd          j        d           |                     t          j        dd          j        d           d S )	Nz(a)?ars   z(a)(b)?brk   r]   z(?P<a>a)(?P<b>b)?bz(?P<a>a(b))z((a)))rf   r:   rg   	lastindexr5   	lastgrouprh   s    r   test_bug_527371zReTests.test_bug_527371:  s    "(8C00:;;;+d33=qAAA"7==GMMM.$77A3GGG(C00:A>>>>>r   c                 (   |                      t          j        dddz  dz                                 d          d           |                      t          j        dddz  d	z   ddz  z   d
z                                 d          d           |                      t          j        dddz  dz                                 d          d           |                      t          j        dddz  dz                                 d          d           d S )Nz.*?cr  rk   rR  r   i!N  z.*?cdi  ru   cdei#N  i N  ro   deia  z(a|b)*?c)r5   r:   rg   r@  rd   rh   s    r   test_bug_418626zReTests.test_bug_418626B  s    	&%*T/::>>qAA5III'49S=d+B5+HIIMMaPP	  	  	 '5;t+;<<@@CCUKKK 	:uTz$??CCAFFNNNNNr   c                     dt          j        d          z   dz   }|                     t          j        |          odd           d S )Nr  u   ‹r  r]   )r:   r  r5   r<   r   s     r   test_bug_612074zReTests.test_bug_612074N  sD    	(###C'C.Q22222r   c                    |                      t          j        dddz                                d          d           |                      t          j        dddz  dz                                 d          d           |                      t          j        dddz  dz                                 d          d           d S )Nz(x)*iP  r1   r]   z(x)*yr2   z(x)*?yr  rh   s    r   test_stack_overflowzReTests.test_stack_overflowR  s     	&%)44::1==sCCC'59S=99??BBCHHH(E#IcM::@@CCSIIIIIr   c                     dD ]?}dD ]:}|                      ||dd           |                      d||ddd           ;@d S )N*+?z{1,2}r   rR  znothing to repeatr   z(?:r  r^   r<  )r   repsmods      r   test_nothing_to_repeatzReTests.test_nothing_to_repeatY  s    * 	? 	?D ? ?&&ss';':A? ? ?&&&TT333'?':A? ? ? ??	? 	?r   c                     dD ]O}dD ]J}||z   }dD ]@}dD ];}||z   dv r
||z   }|                      d||ddt          |          z              <AKPd S )NrO  )r   rR  rQ  )rR  rQ  r1   zmultiple repeatr]   )rC   rC  )r   
outer_reps	outer_modouter_op
inner_reps	inner_modinner_ops          r   test_multiple_repeatzReTests.test_multiple_repeata  s    0 		F 		FJ) F F	%	1"8 F FJ%1 F F	$z1Z??$#-	#9...88XX/N 11s8}}3DF F F F	FFF		F 		Fr   c                    |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     d S )Nz(?:a?)*yr  z(?:a?)+yz(?:a?){2,}yz	(?:a?)*?yz	(?:a?)+?yz(?:a?){2,}?y)rf   r:   rg   rh   s    r    test_unlimited_zero_width_repeatz(ReTests.test_unlimited_zero_width_repeatm  s    "(;44555"(;44555"(>377888"(<55666"(<55666"(?C8899999r   c                    d }d }d }d }t          d|fd|fd|fd|fd	g          }|                     |j                            d
          j                   |                     |                    d          g dd
f           d S )Nc                     |S r   r   scannertokens     r   s_identz%ReTests.test_scanner.<locals>.s_identw  s    E\r   c                     d|z  S )Nzop%sr   rc  s     r   
s_operatorz(ReTests.test_scanner.<locals>.s_operatorx  s    v~(=r   c                      t          |          S r   )floatrc  s     r   s_floatz%ReTests.test_scanner.<locals>.s_floaty  s    E%LL%8r   c                      t          |          S r   )ry   rc  s     r   s_intz#ReTests.test_scanner.<locals>.s_intz  s    #e**#4r   z[a-zA-Z_]\w*z\d+\.\d*r   z=|\+|-|\*|/)z\s+Nr   zsum = 3*foo + 312.50 + bar)	sumzop=r^   zop*fooop+g     s@rp  bar)r   rv  rd  r8   r5   scan)r   rf  rh  rk  rm  rd  s         r   test_scannerzReTests.test_scannerv  s    111===888444g&'"UOZ(   	//33;<<<&BCC) ) )*,.	/ 	/ 	/ 	/ 	/r   c                    dD ]~}|                      t          j        d|z  d                                          d           |                      t          j        d|z  d                                          d           d S )N)r   rR  rP  z
((.%s):)?zr  rg  za:z)r  rs   r5   r:   rg   r/  )r   ops     r   test_bug_448951zReTests.test_bug_448951  s      	* 	*BRXmB&6<<CCEE)+ + +RXmB&6>>EEGG(* * * *	* 	*r   c                    |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        d	d                                          d           |                      t          j        d
d                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           d S )Nz	^((a)|b)*ro   r=  z^(([ab])|c)*)ru   rP   z^((d)|[ab])*rP   Nz^((a)c|[ab])*z^((a)|b)*?cz^(([ab])|c)*?drI  z^((d)|[ab])*?cz^((a)c|[ab])*?cru  rh   s    r   test_bug_725106zReTests.test_bug_725106  s   +u55<<>>#	% 	% 	%.%88??AA#	% 	% 	%.%88??AA$	& 	& 	&/599@@BB$	& 	& 	&-77>>@@#	% 	% 	%"2F;;BBDD#	% 	% 	%"2E::AACC$	& 	& 	&"3U;;BBDD$	& 	& 	& 	& 	&r   c                     |                      t          j        dd                                          d           |                      t          j        dd                                          d           d S )Nz(a)(?:(?=(b)*)c)*rF  )rs   Nz(a)((?!(b)*))*r+  ru  rh   s    r   test_bug_725149zReTests.test_bug_725149  sx    "5u==DDFF$	& 	& 	&"2E::AACC*	, 	, 	, 	, 	,r   c                      G d dt                     }t          j         |d                    }|                     |                    d                     d S )Nc                       e Zd ZdS )+ReTests.test_bug_764548.<locals>.my_unicodeN)r   r   r   r   r   r   
my_unicoder    s          r   r  ro   r   )r{   r:   r<   rf   rg   )r   r  r   s      r   test_bug_764548zReTests.test_bug_764548  s[    ########jE**++#))E**+++++r   c                    t          j        dd          }|                     d |D             g d           t          j        d          }|                    ddd          }|                     d |D             g d           t          j        d          }|                    ddd          }|                     d	 |D             g d           t          j        d          }|                    ddd
          }|                     d |D             g d           t          j        d          }|                    ddd          }|                     d |D             ddg           d S )Nr  r  c                 8    g | ]}|                     d           S r@  rz   r   items     r   
<listcomp>z)ReTests.test_finditer.<locals>.<listcomp>  "    999D$**Q--999r   r  r]   r   c                 8    g | ]}|                     d           S r@  r  r  s     r   r  z)ReTests.test_finditer.<locals>.<listcomp>  r  r   rJ  c                 8    g | ]}|                     d           S r@  r  r  s     r   r  z)ReTests.test_finditer.<locals>.<listcomp>  r  r   )rK  r?   c                 8    g | ]}|                     d           S r@  r  r  s     r   r  z)ReTests.test_finditer.<locals>.<listcomp>  r  r   r^   r   c                 8    g | ]}|                     d           S r@  r  r  s     r   r  z)ReTests.test_finditer.<locals>.<listcomp>  r  r   r  )r:   rM   r5   r<   )r   iterr   s      r   test_finditerzReTests.test_finditer  s   {5,//99D999+++	- 	- 	- j||L!R0099D999+++	- 	- 	- j||La|;;99D999+++	- 	- 	- j||L|;;99D999+++	- 	- 	- j||La|::99D999	' 	' 	' 	' 	'r   c                 z    |                      t          j        d          t          j        d                     d S )N
bug_926075s
   bug_926075)assertIsNotr:   r<   rh   s    r   test_bug_926075zReTests.test_bug_926075  s=    L11M22	4 	4 	4 	4 	4r   c                     d}|                      t          j        |                              d          g d           d S )Nu   [.。．｡]za.b.crS  )r5   r:   r<   r  r   s     r   test_bug_931848zReTests.test_bug_931848  sJ    .G,,227;;&	( 	( 	( 	( 	(r   c                    t          j        dd          }|                     t          |                                          d           |                     t          t          |           t          j        d                              d          }|                     |	                                                                d           | 
                    |	                                           d S )Nz\sr  )r]   rm   )r:   rM   r5   nextre   r9   StopIterationr<   rd  rd   rf   )r   r  rd  s      r   test_bug_581080zReTests.test_bug_581080  s    {5%((d**E222-t444*U##++E22))..00&999'..**+++++r   c                 F   t          j        dd          }|                     t          |                                          d           |                     t          |                                          d           |                     t          t          |           d S )Nz.*asdfrH  )r   r   )r:   rM   r5   r  re   r9   r  )r   r  s     r   test_bug_817234zReTests.test_bug_817234  s}    {5&))d**F333d**F333-t44444r   c                     g d}|D ]>}|                      t          j        d|                              d          |           ?g d}|D ]*}|                     t          j        d|                     +d S )N)7u   ๘u   ０z^\d$r   )u   Ⅵu   〹u   ₂u   ㊴)r5   r:   rg   rz   rf   )r   decimal_digitsr1   not_decimal_digitss       r   test_bug_6561zReTests.test_bug_6561  s      
   	? 	?ARXgq1177::A>>>>   $ 	4 	4Abhw223333	4 	4r   c                 P   dd l }dD ]}|                     |          }|                     t          j        d                              |                     |                     t          j        d                              |                                          d           d S )Nr   bBuhHiIlLfds   blar   r   )arrayrf   r:   r<   rg   r5   r/  )r   r  typecoders   s       r   test_empty_arrayzReTests.test_empty_array  s    % 	D 	DHH%%Abj0066q99:::RZ__22155<<>>CCCC	D 	Dr   c                 \	   d}d}t          j        d|z   t           j        t           j        z            }|                    d|z             }|                     |           t          j        d|z   t           j        t           j        z            }|                    d|z             }|                     |           t          j        d|z   t           j                  }|                    d|z             }|                     |           t          j        d|z   t           j                  }|                    d|z             }|                     |           t          j        d|z             }|                    d|z             }|                     |           t          j        d|z             }|                    d|z             }|                     |           t          j        d|z             }|                    d|z             }|                     |           t          j        d|z             }|                    d|z             }|                     |           |                     t          j        d|z   |                     |                     t          j        d|z   |                     |                     t          j        d	|z   |t           j                             |                     t          j        d
|z   |                     |                     t          j        d|z   |t           j                             d}|                     |dz   |d           t          j	                    5  t          j
        dt                     |                     d|d           d d d            n# 1 swxY w Y   |                     d|z   |d           |                     d|z   dz   |d           |                     d|z   |d           |                     d|z   |d           |                     d|z   |d           |                     d|z   dz   |d           |                     d|z   dz   |d           |                     d|z   dz   |d           d S ) Nu   Ạu   ạr   r   z(?i).z(?is).z	(?s)(?i).z(?ix) z (?i) z
(?x) (?i) z (?x) (?i) z/global flags not at the start of the expressionz(?i)r]   r;   s   A(?i)z	(?s).(?i)r   z(?i) z (?x)r   z^(?i)z$|(?i)rm   z(?:(?i)r  r^   z(^)?(?(1)(?i)r   z($)?(?(1)|(?i)r   )r:   r<   r   r   rg   rv  r   rC   warningscatch_warningssimplefilterBytesWarning)r   
upper_char
lower_charrW  qr3   s         r   test_inline_flagszReTests.test_inline_flags  sw   

JsZ'55GGD:%&&JsZ'55GGD:%&&Jw+RT22GGD:%&&Jw+RT22GGD:%&&Jx*,--GGD:%&&Jx*,--GGD:%&&J{Z/00GGD:%&&J{Z/00GGD:%&&J!6
CCDDDJ!6
CCDDDJ!6
BDIIJJJ
!:JGGHHH!;ZNNOOO?zF2C;;; $&& 	5 	5!'<888""8S!444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	{Z7a@@@w3g=sAFFF}z93BBBw3S!<<<x*4c1===y:5;S!DDD;cA3JJJ/*<sBCLLLLLs   2OO	O	c                 d   t          j        d          }|                     |                    dd          d           |                     |                    dd          d           |                     |                    dd          d           t          j        dt           j                  }|                     |                    dd          d	           |                     |                    dd          d
           |                     |                    dd          d           dS )zgTest that $ does not include \n
        $ matches the end of string, and just before the terminating \n$#za
b
za
b#
#za
b
cza
b
c#r   z#
#za#
b#
#za#
b#
c#N)r:   r<   r5   rF   r  r   s     r   test_dollar_matches_twicez!ReTests.test_dollar_matches_twice>  s    *S//S(33Z@@@S)44jAAAS$//888*S",//S(44kCCCS)44lCCCS$//88888r   c                 r   t          j        d          }t          j        d          }|                     t          |j        d           |                     t          |j        d           |                     t          |j        dd           |                     t          |j        dd           |                     t          |j        dd           |                     t          |j        dd           |                     t          |j        dd           |                     t          |j        dd           d S )Nr      .r	  rP   ru   r
  )r:   r<   r9   rB  rg   rF   )r   r   bpats      r   test_bytes_str_mixingzReTests.test_bytes_str_mixingK  s    jooz$)SY555)TZ555)SWdC888)SWc4888)SWdD999)TXtS999)TXsD999)TXsC88888r   c                    dt           j        fD ]}t          j        d|t           j        z            }|                     |                    d                     t          j        d|          }|                     |                    d                     t          j        dt           j        t           j        z            }|                     |                    d                     t          j        dt           j                  }|                     |                    d                     t          j        dt           j                  }|                     |                    d                     t          j        d          }|                     |                    d                     dt           j        fD ]}t          j        d|t           j        z            }|                     |                    d                     t          j        d	|          }|                     |                    d                     |                     t          t           j        d	t           j                   |                     t           j
        t           j        d
           |                     t          t           j        dt           j        t           j        z             |                     t          t           j        dt           j                   |                     t          t           j        dt           j                   |                     t           j
        t           j        d           d S )Nr      Àr   z\wu   (?a)Àz(?a)\w         \ws   (?u)\wz(?u)\wz(?au)\w)r:   r  r<   r  rv  rg   r  rf   r9   r   r;   )r   rz  r   s      r   test_ascii_and_unicode_flagz#ReTests.test_ascii_and_unicode_flagX  s   _ 	/ 	/E*VUR]%:;;COOCIIf--...*UE**COOCIIf--....jBM!9::#))F++,,,jR]33#))F++,,,j))#))F++,,,j###))F++,,,] 	2 	2E*Webm&;<<Ccii00111*VU++Ccii001111*bj&"*EEE"(BJ
;;;*bj%bh9NOOO*bj)RXFFF*bj)RZHHH"(BJ
;;;;;r   c                    t          j                    }t          dd          D ]}	 t          |g                              |          }|                                }||k    rA|                    |          }t          |          dk    rj|                    |          |k    rt          j	        t          |g                    } n# t          t          f$ r Y w xY wd }d}t          j        |t          j        t          j        z            }|r(|                     |                    |                     t          j        d|z   t          j                  }|r(|                     |                    |                     t          j        |t          j                  }|r(|                     |                    |                     t          j        dt          j                  }|r(|                     |                    |                     t          j        d          }|r(|                     |                    |                     t          j        d          }|r(|                     |                    |                     |                     t&          t          j        dt          j                   |                     t          j        t          j        d	           |                     t&          t          j        d
t          j        t          j        z             |                     t&          t          j        dt          j                   |                     t&          t          j        dt          j                   |                     t          j        t          j        d           d S )Nr  r]  r]   r  s   (?L)r  s   (?L)\wr   z(?L)r   s   (?a)s   (?aL))localegetpreferredencodingr   r  r  lowerr  rC  r:   r  UnicodeErrorrB  r<   r  r  rv  rg   rf   r9   r   r;   r  )r   encr   ru   sletterbletterr  r   s           r   test_locale_flagzReTests.test_locale_flagu  s   )++sC 	 	A
1#JJ%%c**''))a<<!..--w<<1$$h>>#&&'118ys,, ),    GDjry2=899 	0OOCIIg..///j477 	0OOCIIg..///jr}-- 	2cii00111j++ 	0OOCIIg..///j$$ 	0OOCIIg..///j   	2cii00111*bj"bi@@@"(BJ777*bj#ry287KLLL*bj'28DDD*bj'29EEE"(BJ99999s#   =C%(CC("CC C c                    |                      t          j        dd                     |                     t          j        dd                     |                     t          j        ddt          j                             |                      t          j        ddt          j                             |                     t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        d	dt          j                             |                     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 )&Nz(?i:a)bAbaBz(?-i:a)bz(?i:(?-i:a)b)z\w(?a:\W)\wu   àààz(?a:\W(?u:\w)\W)z\W(?u:\w)\Wz(?a)(?-a:\w)z8bad inline flags: cannot turn off flags 'a', 'u' and 'L'r   z(?i-i:a)z(bad inline flags: flag turned on and offr   z(?au:a)z9bad inline flags: flags 'a', 'u' and 'L' are incompatibler   s   (?aL:a)z(?-zmissing flagr^   z(?-+z(?-zunknown flagz(?-iz	missing :z(?-i)z(?-i+z(?-izz(?i:rZ  r   (?imissing -, : or )z(?i+z(?iz)rv  r:   rg   rf   r  r  rC   rh   s    r   test_scoped_flagszReTests.test_scoped_flags  s   T22333"(:t44555"(;bmDDEEEdBMBBCCC"(#3T::;;;!1488999@@AAA!4nEEFFFJJKKKJA	O 	O 	O{:A	? 	? 	?zKQ	P 	P 	P{KQ	P 	P 	P 	v~q999w:::w:::wQ777xa888xa888x;;;w(LaPPPv':A>>>w(;Q???w:::::r   c                    dD ]8}|                      t          j        |dz   dt          j                             9dD ]8}|                      t          j        |dz   dt          j                             9|                      t          j        dd                     |                      t          j        ddt          j                             |                      t          j        dd                     |                      t          j        dd	                     |                      t          j        d
dt          j                             |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     d S )Nz 	
rs   )       	   
         rK   z(?x) az (?x) az(?x) (?x) az a(?x: b) cz ab cz a(?-x: b) cr  z(?x) a(?-x: b) cz	(?x) a| brP   rv  r:   rL  r  )r   spaces     r   test_ignore_spaceszReTests.test_ignore_spaces  su   " 	H 	HEOOBLc2:FFGGGG< 	J 	JEOOBLtRZHHIIIIXs33444YRZ@@AAA]C88999]G<<===^VRZHHIII%7@@AAA[#66777[#6677777r   c                 ~   |                      t          j        ddt          j                             |                      t          j        ddt          j                             |                      t          j        dd                     |                      t          j        ddt          j                             |                      t          j        dd                     |                      t          j        dd	                     |                      t          j        d
dt          j                             |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     d S )Nz#x
ars   s   #x
arK   z(?x)#x
az#x
(?x)#y
az(?x)#x
(?x)#y
az#x
a(?x:#y
b)#z
cz	#x
ab#z
cz#x
a(?-x:#y
b)#z
cza#y
bcz(?x)#x
a(?-x:#y
b)#z
cz(?x)#x
a|#y
brP   r  rh   s    r   test_commentszReTests.test_comments  sU   Wc2:>>???XtRZ@@AAA[#66777_c2:FFGGG%8#>>???%;]KKLLL%<i%'Z1 1 	2 	2 	2%@)LLMMM%6<<===%6<<=====r   c                    t          j        d          }|                     |                    dd          d           t          j        d          }|                     |                    dd          d           t          j        d          }|                     |                    d	 d
          d           t          j        d          }|                     |                    dd          d           t          j        d          }|                     |                    dd          d           t          j        d          }|                     |                    d d          d           d S )Nza(\w)zb\1r(  r)  za(.)u   aሴu   bሴz..c                     dS )Nr{   r   r   s    r   r   z'ReTests.test_bug_6509.<locals>.<lambda>  s    5 r   a5r{   s   a(\w)s   b\1s   acs   bcs   a(.)s   as   bs   ..c                     dS )N   bytesr   r   s    r   r   z'ReTests.test_bug_6509.<locals>.<lambda>  s    8 r   s   a5r  )r:   r<   r5   rF   r   s     r   test_bug_6509zReTests.test_bug_6509  sD    j""..555j  33Y???j$77??? j##%00%888j!!(33X>>>j!3!3U;;XFFFFFr   c                    |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     d S )Nz123.*-z123abc-u   123é-u   123€-u   123􏿿-u   123é€􏿿-)rv  r:   rd   rh   s    r   test_search_dot_unicodezReTests.test_search_dot_unicode  s    	(I66777	(J77888	(L99:::	(,<==>>>	(,FGGHHHHHr   c                 N   t          j        d          }|                     |t           j                   t          j        |          }|                     |t           j                   |                     ||           |                     t          t           j        d           d S )Nrandom patternr   )r:   r<   assertIsInstancePatternr-   r9   rB  )r   r8   same_patterns      r   test_compilezReTests.test_compile  s    *-..grz222z'**lBJ777lG,,,)RZ33333r   r]   )sizememusec                    d|z  }t          j        d|          }|                     |           |                     |                                |           |                     |                                |           d S )Nrs   r  )r:   rd   assertIsNotNoner5   r?  r@  )r   r  rV   r   s       r   test_large_searchzReTests.test_large_search  st     $JIc1QD)))$'''''r      c                     d|z  }t          j        dd|          \  }}|                     ||           |                     ||dz              d S )Nrs   r   r]   )r:   r   r5   )r   r  rV   rM  ns        r   test_large_subnzReTests.test_large_subn  sZ     $Jwr2q!!1AD1H%%%%%r   c                     |                      t          j        dd          dg           |                      t          j        dd                                          d           d S )Nz	(?i)(a)\1u   aa Ārs   z
(?s).{1,3}u   ĀĀrl   )r5   r:   rU   rg   re   rh   s    r   test_bug_16688zReTests.test_bug_16688  s\     	L+>>FFF-@@EEGGPPPPPr   c                 >   ddz  }|                      t          j        d|                                          d           |                      t          j        d|                                          d           |                      t          j        d|                                          d           |                      t          j        d|                                          d           |                      t          j        d	|                                          d           |                      t          j        d
|                                          d           |                     t
          t          j        dddz  z             |                     t
          t          j        dddz  z             |                     t
          t          j        dddz  z             |                     t
          t          j        dddz  ddz  fz             d S )Nr1   順 z.{65535})r   r  z	.{,65535}z
.{65535,}?z.{65536})r   r  z	.{,65536}z
.{65536,}?.{%d}rm   r  .{,%d}.{%d,}?z.{%d,%d}   )r5   r:   rg   re   r9   OverflowErrorr<   )r   rG   s     r   test_repeat_minmax_overflowz#ReTests.test_repeat_minmax_overflow  s   v+v66;;==zJJJ,77<<>>
KKK-88==??LLL+v66;;==zJJJ,77<<>>
KKK-88==??LLL-X35FGGG-YC5GHHH-Z!S&5HIII-[AsFAsFCS5STTTTTr   c                 4    |                      ddd           d S )Nz
(?P=<foo>)z#bad character in group name '<foo>'r   r<  rh   s    r   $test_backref_group_name_in_exceptionz,ReTests.test_backref_group_name_in_exception)  s0    |Da	I 	I 	I 	I 	Ir   c                 4    |                      ddd           d S )Nz
(?P<?foo>)z"bad character in group name '?foo'r   r<  rh   s    r   test_group_name_in_exceptionz$ReTests.test_group_name_in_exception.  s0    |CQ	H 	H 	H 	H 	Hr   c                 |   dD ]}dD ]}d|z   |z   dz   }|                      t          j        |t          j                                      d          dg|           |                                }|                      t          j        |t          j                                      d          dg|           d S )N)rP  rQ  rR  z{1}rS  r   yzr   )r3   r   )r5   r:   r<   r   rU   r  )r   rT  rU  r8   s       r   test_issue17998zReTests.test_issue179983  s    ( 	8 	8D 8 8*s*T1  GRT!:!:!B!B5!I!I"'g ! 7 7 7!..**  GRT!:!:!B!B6!J!J"(w ! 8 8 8 88	8 	8r   c                    dt          d          fD ]g}t          j        d|          }dt          |          j        dt          |          j        d}|                     t          |          |           hdt          d          t          d          t          d          fD ]g}t          j        d|          }dt          |          j        dt          |          j        d}|                     t          |          |           ht          t          j        d	d
                    \  }}dt          |          j        dt          |          j        d}|                     t          |          |           dt          |          j        dt          |          j        d}|                     t          |          |           d S )Nz[abracadabra]z(.+)(.*?)\1z<(z\.)?z- object; span=\(1, 12\), match='abracadabra'>s   [abracadabra]s   (.+)(.*?)\1z. object; span=\(1, 12\), match=b'abracadabra'>z	(aa)|(bb)zaa bbz# object; span=\(0, 2\), match='aa'>z# object; span=\(3, 5\), match='bb'>)r   r:   rd   r.   r   r   assertRegexreprr#   rL   r   r+   rM   )r   rG   r   r8   rl  rm  s         r   test_match_reprzReTests.test_match_repr=  s   %q'9'99 	/ 	/F	.&11AAQ"""DGG$8$8$8G T!WWg....'+;)<)< !122!"2335 	/ 	/F 	/622AAQ"""DGG$8$8$8G T!WWg....R[g>>??vvLL###T&\\%>%>%>
 	eg....LL###T&\\%>%>%>
 	fw/////r   c                    |                      t          j        dd          g d           |                      t          j        dd          g d           |                      t          j        dd          g d           |                      t          j        dd          g d	           |                      t          j        dd
d          d           |                      t          j        dd
d          d           |                      t          j        ddd          d           |                      t          j        dd          g d           |                      t          j        dd          g d           |                      d t          j        dd          D             g d           |                      d t          j        dd          D             g d           d S )Nr  za::bc)r   rs   r  r)  r   z\b|:+)r   rs   r   r   r)  r   z(?<!\w)(?=\w)|:+)r   rs   r   r)  z(?<=\w)(?!\w)|:+)rs   r   r)  r   r  z	-a-::-bc-z-a---bc-z(\b|:+)z[\1]z[]a[][::][]bc[])r   r   r  r   r   z\b|\w+c                 6    g | ]}|                                 S r   re   r   r   s     r   r  z*ReTests.test_zerowidth.<locals>.<listcomp>f  s     KKKq!&&((KKKr   )r[   r]   r]   r\   r^   r^   r   r   c                 6    g | ]}|                                 S r   r  r  s     r   r  z*ReTests.test_zerowidth.<locals>.<listcomp>h  s     LLLq!&&((LLLr   )r[   rt   r	  r
  )r^   r   r  )r5   r:   r  rF   rU   rM   rh   s    r   test_zerowidthzReTests.test_zerowidthW  s   %113L3L3LMMM(G446Q6Q6QRRR"5w??ATATATUUU"5w??ATATATUUUsG44kBBB#w77DDD
GW==?PQQQHg668N8N8NOOOIw77444	6 	6 	6 	KKBK',J,JKKKAAA	C 	C 	CLLBK	7,K,KLLLIII	K 	K 	K 	K 	Kr   c                 n   dD ]}dD ]}t          j        d|d|          }|                    d          }|                     |                    d          d           |                     |                    d          d	           |                     |                    d
          d           d S )N){0,}rP  rQ  z{1,187})r  rP  rR  z^((x|y)r  xyyzyr   xyyr]   r   rm   r2   )r:   r<   rg   r5   rz   )r   rZ  r]  rM  r   s        r   test_bug_2537zReTests.test_bug_2537k  s    5 	2 	2H. 2 2JJ88DEEGGG$$  U333  R000  S11112	2 	2r   c                    t          j        d          }|                     |                    ddd                                          d           |                     |                    ddd                                          d           |                     |                    ddd                                          d           |                     |                    ddd          d	g           |                     |                    dd
          g d           |                     |	                    ddd                                                                          d           d S )Nz(ab)abracadabrar   r   )rG   r?   rK  )r   r   r   r^   rk   r]   )rG   r  )r   rk   	racadabra)
r:   r<   r5   rg   re   rL  rd   rU   r  rd  r   s     r   test_keyword_parameterszReTests.test_keyword_parametersu  s   j!!II]"I==BBDDf	N 	N 	NMMAaM@@EEGG	Q 	Q 	QJJm2J>>CCEEv	O 	O 	OKK}!BK??$	I 	I 	III]QI77###	% 	% 	% 	KK}!BK??FFHHMMOO	 	 	 	 	r   c                     |                      t          j        ddt          j                                                  d           d S )Nz[a-c]+r  rb   )r5   r:   rL  r   re   rh   s    r   test_bug_20998zReTests.test_bug_20998  s<     	hrt<<AACCVLLLLLr   z-musl libc issue on Emscripten/WASI, bpo-46390c                 (   t          j        t           j                  }|                     t           j        t           j        |           dD ]O}	 t          j        t           j        |           ## t           j        $ r |                     d|z             Y Lw xY wt          j                     |                                  | 	                                 t          j                     | 	                                 |                                  d S )Nen_US.iso88591
en_US.utf8test needs %s locale)
r  	setlocaleLC_CTYPE
addCleanupErrorskipTestr:   r  check_en_US_iso88591check_en_US_utf8)r   	oldlocalelocs      r   test_locale_cachingzReTests.test_locale_caching  s     $V_55	(&/9EEE1 	< 	<C< #6666< < < <4s:;;;;;< 	


!!###



!!#####   A//'BBc                    t          j        t           j        d           |                     t	          j        ddt          j        t          j        z                       |                     t	          j        ddt          j        t          j        z                       |                     t	          j        ddt          j        t          j        z                       |                     t	          j        dd                     |                     t	          j        dd                     |                     t	          j        dd                     d S )Nr              (?Li)   (?Li)   (?Li))r  r  r  rv  r:   rg   r  r   rh   s    r   r#  zReTests.check_en_US_iso88591  s    *:;;;k249EEFFF'249==>>>'249==>>>!1;??@@@w77888w7788888r   c                    t          j        t           j        d           |                     t	          j        ddt          j        t          j        z                       |                     t	          j        ddt          j        t          j        z                       |                     t	          j        ddt          j        t          j        z                       |                     t	          j        dd                     |                     t	          j        dd                     |                     t	          j        dd                     d S )Nr  r*  r+  r,  r-  r.  r/  )	r  r  r  rv  r:   rg   r  r   rf   rh   s    r   r$  zReTests.check_en_US_utf8  s    ,777k249EEFFF"(7GRT"$Y??@@@"(7GRT"$Y??@@@!1;??@@@"(<99:::"(<99:::::r   c                    t          j        t           j                  }|                     t           j        t           j        |           dD ]O}	 t          j        t           j        |           ## t           j        $ r |                     d|z             Y Lw xY wt          j        t           j        d           t          j        dt          j        t          j	        z            }t          j        dt          j        t          j	        z            }t          j        dt          j        t          j	        z            }t          j        dt          j        t          j	        z            }|||fD ]z}| 
                    |                    d                     | 
                    |                    d                     | 
                    |                    d	                     {|                     |                    d
                     |                     |                    d                     |                     |                    d	                     t          j        t           j        d           |||fD ]z}| 
                    |                    d                     |                     |                    d                     |                     |                    d	                     {| 
                    |                    d
                     |                     |                    d                     |                     |                    d	                     d S )Nr  r  r  r*  s   [a][a]s
   [az][az]s   [^][^]s   s   s   r  )r  r  r  r   r!  r"  r:   r<   r  r   rv  rg   rf   )r   r%  r&  p1p2p3p4rW  s           r   test_locale_compiledzReTests.test_locale_compiled  s   
 $V_55	(&/9EEE1 	< 	<C< #6666< < < <4s:;;;;;< 	*:;;;ZRT"$Y//Z)24955Z+RT"$Y77Z)24955R 	2 	2AOOAGGK00111OOAGGK00111OOAGGK001111"((;//000"((;//000"((;//000,777R 	4 	4AOOAGGK00111aggk22333aggk223333--..."((;//000"((;//00000r(  c                    |                      t          j                  5 }t          j        d           d d d            n# 1 swxY w Y   |j        }|                     |j        t                     |                     |j        d           |                     |j	        d           |                     |j
        d           |                     |j        d           |                     |j        t          |                     |                     dt          |                     |                     d|j                   |                      t          j                  5 }t          j        d           d d d            n# 1 swxY w Y   |j        }|                     |j        t                     |                     |j        d           |                     |j	        d           |                      t          j                  5 }t          j        dt          j                   d d d            n# 1 swxY w Y   |j        }|                     |j	        d           |                     |j
        d	           |                     |j        d
           |                     |j        t          |                     |                     dt          |                     |                     dt          |                     d S )Nu   (€))r^   r]   r   z at position 3s   ())zq
                (
                    abc
                )
                )
                (
                M   r      z at position 77z(line 5, column 17))r9   r:   r;   r<   r>   r  r8   r{   r5   r?   linenocolnoassertInr3   assertNotInr  r  )r   rA   rB   s      r   
test_errorzReTests.test_error  sA   rx(( 	$BJ{###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$lck3///k222!$$$Q'''A&&&cgs3xx(((&C111)37333rx(( 	#BJz"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#lck5111j111!$$$rx(( 	!BJ  Z! ! !	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! l"%%%Q'''B'''cgs3xx((('S222+SXX66666s5   AAA$FF	F	 H88H<?H<c                     |                      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 )Nr  rZ  r   z((a|b)z(a|b))zunbalanced parenthesisr   z(?Pzunexpected end of patternr^   z(?z)zunknown extension ?zr]   z(?iz)r  r  r  z(?#abczmissing ), unterminated commentz(?<z(?<>)zunknown extension ?<>z(?rm   r<  rh   s    r   test_misc_errorszReTests.test_misc_errors  s   t%I1MMMy*NPQRRRy*BAFFFv'BAFFFw(>BBBx;;;v':A>>>y*KQOOOv'BAFFFx)@!DDDu&A1EEEEEr   c                     |                      dt          t          j                             |                      dt          t          j                             d S )Nr  r  )r<  r{   r:   r   r   rh   s    r   	test_enumzReTests.test_enum	  sB     	gs24yy)))hBD		*****r   c                    t          j        dt           j                  }|                     ||           |                     ||k               t          j                     t          j        dt           j                  }|                     t          |          t          |                     |                     ||           t          j                     t          j        dt           j                  }|                     ||           t          j                     t          j        d          }|                     ||           |                     t                    5  ||k      d d d            d S # 1 swxY w Y   d S )Nro   XYZ)
r:   r<   r  r5   r  r  hashassertNotEqualr9   rB  )r   pattern1pattern2pattern3pattern4s        r   test_pattern_comparezReTests.test_pattern_compare  s   :eR]33 	8,,,X-... 	


:eR]33hh8888,,, 	


:eR]33 	Hh/// 	


:e$$Hh/// y)) 	  	 x	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   &E::E>E>c                    t          j        d          }t          j                     t          j        d          }|                     t	          |          t	          |                     |                     ||           t          j                     t          j        d          }t          j                    5  t          j        dt                     | 	                    ||           d d d            d S # 1 swxY w Y   d S )Nr  ro   r;   )
r:   r<   r  r5   rE  r  r  r  r  rF  )r   rG  rH  rI  s       r   test_pattern_compare_bytesz"ReTests.test_pattern_compare_bytes,  s   :f%% 	


:f%%hh8888,,, 	


:e$$$&& 	4 	4!'<888(333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   <1C::C>C>c                    t          d          }t          j        d|          }t          j        d|          }|                     |                                d           |                     |                                d           d|d d <   |                     |                                d           |                     |                                d           d S )Ns   abcdefghs   [a-h]+s   [e-h]+s   efghr   r   )rL   r:   rd   r5   rz   )r   rV   r   m2s       r   test_bug_29444zReTests.test_bug_29444=  s    k""Ii##Yy!$$K000W---!!!F+++S)))))r   c                    d}d}|                      t          j        ||                                          d           d}d}|                      t          j        ||          ddg           |                      d t          j        ||          D             dd	g           d
}d}|                      t          j        ||          ddg           |                      d t          j        ||          D             ddddd dg           d}|                      d t          j        ||          D             ddddd dg           d}|                      d t          j        ||          D             ddddd ddd dg           d S )Nza	xz\b(?=(\t)|(x))x)Nr1   rk   z(?=(.)(.)?)rQ  )rP   r   c                 6    g | ]}|                                 S r   )r/  r  s     r   r  z*ReTests.test_bug_34294.<locals>.<listcomp>T  s     @@@!((**@@@r   ry  z1(?=<(?P<tag>\w+)/?>(?:(?P<text>.+?)</(?P=tag)>)?)z<test><foo2/></test>)r   <foo2/>)foo2r   c                 6    g | ]}|                                 S r   rn  r  s     r   r  z*ReTests.test_bug_34294.<locals>.<listcomp>\       CCCA!++--CCCr   r   rS  )tagr  rT  z<test>Hello</test><foo/>c                 6    g | ]}|                                 S r   rV  r  s     r   r  z*ReTests.test_bug_34294.<locals>.<listcomp>`  rW  r   Helloro  z<test>Hello</test><foo/><foo/>c                 6    g | ]}|                                 S r   rV  r  s     r   r  z*ReTests.test_bug_34294.<locals>.<listcomp>d  rW  r   )r5   r:   rd   r/  rU   rM   r  s      r   test_bug_34294zReTests.test_bug_34294G  s    1a//11;??? Aq))$i0	2 	2 	2@@bk!Q.?.?@@@$k2	4 	4 	4 A"Aq))-|<	> 	> 	>CCQ1B1BCCC"()<<"($779	: 	: 	: 'CCQ1B1BCCC"('::"'668	9 	9 	9 -CCQ1B1BCCC"('::"'66"'668	9 	9 	9 	9 	9r   c                    |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           d S )Nz	(ab|a)*?brk   r&  z	(ab|a)+?bz(ab|a){0,2}?bz	(.b|a)*?bru  rh   s    r   test_MARK_PUSH_macro_bugz ReTests.test_MARK_PUSH_macro_bugi  s     	,55<<>>GGG,55<<>>GGG"2D99@@BBFKKK,55<<>>GGGGGr   c                    d}d}|                      t          j        ||                                          d           d}d}t          j        ||          }|                      |                                d           |                      |                    d          d           |                      |                                d	           d S )
Naxxzbczz(?:(?:a|bc)*?(xx)??z)*r   xtcxyzxcz((x|yz)+?(t)??c)*)r   r   rm   )   r   )xyzxcr1   tr5   r:   rg   r/  re   r   rV   rW  r   s       r   test_MIN_UNTIL_mark_bugzReTests.test_MIN_UNTIL_mark_bugq  s     %!Q..00':::  HQNN6***F+++%899999r   c                    d}d}t          j        ||          }|                     |                                d           |                     |                    d          d           |                     |                                d           d}d}t          j        ||          }|                     |                                d	           |                     |                    d          d
           |                     |                                d           |                     t          j        dd                                          d           d S )Naabaabz(?:[^b]*a(?=(b)|(a))ab)*)r   rc  rm   )r   r   rP  ababz(?:[^b]*(?=(b)|(a))ab)*rH  )rm   r^   z(ab?)*?brk   r&  r:   rg   r5   re   r/  rg  s       r   test_REPEAT_ONE_mark_bugz ReTests.test_REPEAT_ONE_mark_bug  s$    'HQNN6***F+++[111 &HQNN6***F+++[111+t44;;==vFFFFFr   c                    d}d}t          j        ||          }|                     |                                d           |                     |                    d          d           |                     |                                d           d}d}|                     t          j        ||                                          d	           d S )
Nrk  z(?:.*?(?=(a)|(b))b)*rH  rm   r^   r   )NrP   axxzazz(?:a*?(xx)??z)*ra  rl  rg  s       r   test_MIN_REPEAT_ONE_mark_bugz$ReTests.test_MIN_REPEAT_ONE_mark_bug  s     #HQNN6***F+++[111!Q..00':::::r   c                    |                      t          j        dd                                          d           t          j        dd          }|                      |                                d           |                      |                    d          d           |                      |                    d	          d           |                      |                                d
           d S )Nz	(?!(..)c)rk   r   z((?!(ab)c)(.))*rk  rH  r]   ro  r^   )rP   NrP   rf  )r   r   s     r   test_ASSERT_NOT_mark_bugz ReTests.test_ASSERT_NOT_mark_bug  s     	,55<<>>HHH H'006***F+++F+++%566666r   c                 2   |                      t          d          5  t          j        dd           d d d            n# 1 swxY w Y   |                      t          d          5  t          j        dt                     d d d            d S # 1 swxY w Y   d S )Nz	got 'int'rY   r   z
got 'type')r   rB  r:   rd   r.   rh   s    r   test_bug_40736zReTests.test_bug_40736  s   ##I{;; 	 	IdA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##I|<< 	" 	"IdD!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s!   >AA$BBBc           	      N   ddz  }t          j                    }dD ]}|                     t          j        ||                     |                     t          j        ||          |g           |                     t          j        ||          g            |                     t          t          j	        ||                    g            |                     t          j
        |d|          |           t          j                    |z
  }|                     |d           d S )Nr1   i )z\Ayz^yr   g?)timeperf_counterrf   r:   rd   r5   r  rU   r+   rM   rF   
assertLess)r   rV   r?  rW  re  s        r   test_search_anchor_at_beginningz'ReTests.test_search_anchor_at_beginning  s
   I!## 	2 	2Abi1oo...RXa^^aS111RZ1--r222T"+a"3"344b999RVAr1--q1111%' 	3r   c                 F
   |                      t          j        dd                     |                     t          j        dd                              d          d           |                     t          j        dd                              d          d           |                     t          j        dd                              d          d           |                      t          j        d	d
                     |                     t          j        dd                                          d           |                     t          j        dd                                          d           |                     t          j        dd                                          d           |                     t          j        dd                                          d           |                     t          j        dd                                          d           |                     t          j        dd                                          d           |                     t          j        dd                                          d           |                     t          j        dd                                          d           |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                     t          j        d d                              d!          d"           |                     t          j        d#d                              d!          d"           |                     t          j        d$d                              d!          d"           |                      t          j        d%d                     |                      t          j        d&d                     |                     t          j        d'd                     |                     t          j        d(d                     |                     t          j        d)d                     |                      t          j        d*d                     |                     t          j        d*d+                     d,S )-a  Test Possessive Quantifiers
        Test quantifiers of the form @+ for some repetition operator @,
        e.g. x{3,5}+ meaning match from 3 to 5 greadily and proceed
        without creating a stack frame for rolling the stack back and
        trying 1 or more fewer matches.ze*+eeeeeze++aeeear   ze?+aeaze{2,4}+az(.)++.eez(ae)*+aaea)aez([ae][ae])?+az(e?){2,4}+a)r   z()*+ars   zx*+rZ   r[   zx++r\   a*+r`   ra   rb   a++z
^(\w){1}+$ro   z^(\w){1,2}+$z
^(\w){3}+$r]   ru   z^(\w){1,3}+$z^(\w){1,4}+$z^x{1}+$z	^x{1,2}+$z^x{3}+$z	^x{1,3}+$z	^x{1,4}+$z^x{}+$ru  N)	rf   r:   rg   r5   rz   r/  rd   re   rv  rh   s    r   test_possessive_quantifiersz#ReTests.test_possessive_quantifiers  s     	"(6622333&&1177::FCCC&$//55a88$???*f55;;A>>GGG"(8T22333)U33::<<gFFF/599@@BB 	" 	" 	"-88??AA	  	  	 '3//6688%@@@5%005577@@@5%005577@@@%//4466???%005577@@@"(5%00111"(=%88999"(?E::;;;-77==a@@#FFF/599??BBCHHH/599??BBCHHH"(9e44555"(;66777E22333e44555e44555"(8U3344451122222r   c                    |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        d	d                     |                      t          j        d
d                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     d S )Nr  rs   r  a?+a{1,3}+rk   za++bza*+bza?+bza{1,3}+b(?:ab)++(?:ab)*+(?:ab)?+(?:ab){1,3}+ro   z	(?:ab)++cz	(?:ab)*+cz	(?:ab)?+cz(?:ab){1,3}+crv  r:   rL  rf   rh   s    r   %test_fullmatch_possessive_quantifiersz-ReTests.test_fullmatch_possessive_quantifiers  s   VS11222VS11222VS11222Z55666",vt44555",vt44555",vt44555",z488999Wd33444Wd33444Wd33444[$77888[$77888[$77888[$77888_d;;<<<",{E::;;;",{E::;;;",{E::;;;",>>???\599:::\599:::\599:::%5u==>>>>>r   c                    |                      t          j        dd          dg           |                      t          j        dd          g d           |                      t          j        dd          g d           |                      t          j        dd          dg           |                      t          j        d	d
          dg           |                      t          j        dd
          g d           |                      t          j        dd
          g d           |                      t          j        dd
          dg           d S )Nr  aabrf  r  rf  r   r   r  rs   rs   r   r   r  r  ababcrk  r  rk  r   r   r  rk   rk   r   r   r  r"  rh   s    r   #test_findall_possessive_quantifiersz+ReTests.test_findall_possessive_quantifiers	  s9   FE22TF;;;FE22NNNCCCFE224F4F4FGGGJ66???K99F8DDDK99;K;K;KLLLK99;O;O;OPPPOW==xHHHHHr   c                 ^   t          j        d          }|                     |                    d                     |                     |                    d                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        d	d                     d
S )zTest Atomic Grouping
        Test non-capturing groups of the form (?>...), which does
        not maintain any stack point created within the group once the
        group is finished being evaluated.z
a(?>bc|b)cro   abccz(?>.*).z(?>x)++r`   z(?>x++)z(?>x)++xz(?>x++)xN)r:   r<   rf   rg   rv  )r   rG  s     r   test_atomic_groupingzReTests.test_atomic_grouping	  s    
 :m,,(..//000v..///"(:u55666U33444U33444"(;66777"(;6677777r   c                    |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        d	d                     |                      t          j        d
d                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                     t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     |                      t          j        dd                     d S )N(?>a+)rs   (?>a*)(?>a?)
(?>a{1,3})rk   z(?>a+)bz(?>a*)bz(?>a?)bz(?>a{1,3})b(?>(?:ab)+)(?>(?:ab)*)(?>(?:ab)?)(?>(?:ab){1,3})ro   z(?>(?:ab)+)cz(?>(?:ab)*)cz(?>(?:ab)?)cz(?>(?:ab){1,3})cr  rh   s    r   test_fullmatch_atomic_groupingz&ReTests.test_fullmatch_atomic_grouping	  s   Y44555Y44555Y44555]C88999",y$77888",y$77888",y$77888",}d;;<<<Z66777Z66777Z66777^T::;;;^T::;;;^T::;;;^T::;;;%7>>???",~u==>>>",~u==>>>",~u==>>>",'95AABBB_e<<===_e<<===_e<<===%8%@@AAAAAr   c                    |                      t          j        dd          dg           |                      t          j        dd          g d           |                      t          j        dd          g d           |                      t          j        dd          dg           |                      t          j        d	d
          dg           |                      t          j        dd
          g d           |                      t          j        dd
          g d           |                      t          j        dd
          dg           d S )Nr  r  rf  r  r  r  r  r  r  r  rk  r  r  r  r  r  r"  rh   s    r   test_findall_atomic_groupingz$ReTests.test_findall_atomic_grouping8	  s:   Iu55v>>>Iu55~~~FFFIu557I7I7IJJJM599D6BBBNG<<vhGGGNG<<>N>N>NOOONG<<>R>R>RSSS$6@@6(KKKKKr   c                     |                      t          j        dd                     |                      t          j        dd                     d S )Nz(?s:(?>.*?\.).*)\Zza.txtz!(?s:(?=(?P<g0>.*?\.))(?P=g0).*)\Z)rv  r:   rL  rh   s    r   test_bug_gh91616zReTests.test_bug_gh91616C	  sF    %:GDDEEE%I7SSTTTTTr   c                    |                      t                    5 }t          j        d          }d d d            n# 1 swxY w Y   |                     dt          |j                             |                     dt          |j                             |                     dt          |j                             |                     dt          |j                             |                      t                    5 }t          j        dt          j	        t          j
        z            }d d d            n# 1 swxY w Y   |                     dt          |j                             |                     dt          |j                             |                     dt          |j                             |                     dt          |j                             |                     ||           |                     |                    d                     |                     |                    d	                     d S )
Nrs   zre.template()zis deprecatedfunctionr  )rz  zre.TEMPLATEahoynope)r  r   r:   templater<  r{   warningr=  r<   TEMPLATEr  r5   rv  rg   r  )r   rA   template_re1template_re2s       r   -test_template_function_and_flag_is_deprecatedz5ReTests.test_template_function_and_flag_is_deprecatedG	  sT   011 	-R;t,,L	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-os2:777os2:777j#bj//222RZ111011 	JR
 :d"+bj2HIIIL	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	mS__555os2:777fc"*oo...S__555 	|444**622333++F3344444s!   <A A .D;;D?D?c                 f   |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d	           |                      t          j        d
d                                          d	           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d           |                      t          j        dd                                          d	           |                      t          j        dd                                          d	           |                      t          j        dd                                          d           |                      t          j        dd                                          d           d S )Nz(?>(?:.(?!D))+)ABCDErl   z(?:.(?!D))++z(?>(?:.(?!D))*)z(?:.(?!D))*+z(?>(?:.(?!D))?)CDEr[   z(?:.(?!D))?+z(?>(?:.(?!D)){1,3})z(?:.(?!D)){1,3}+z(?>(?:ab?c)+)acaz
(?:ab?c)++z(?>(?:ab?c)*)z
(?:ab?c)*+z(?>(?:ab?c)?)rs   z
(?:ab?c)?+z(?>(?:ab?c){1,3})z(?:ab?c){1,3}+rv   rh   s    r   test_bug_gh106052zReTests.test_bug_gh106052_	  s   "3W==BBDDfMMM.'::??AA6JJJ"3W==BBDDfMMM.'::??AA6JJJ"3U;;@@BBFKKK.%88==??HHH"7AAFFHH&QQQ"4g>>CCEEvNNN/599>>@@&III,66;;==vFFF/599>>@@&III,66;;==vFFF/377<<>>GGG,4499;;VDDD"5u==BBDDfMMM"2E::??AA6JJJJJr   ztest requires multiprocessingc                    t          j        d          }d}t          j        |j        d|f          }|                                 |                    t                     	 |                     |	                                d           |	                                r*|
                                 |                                 d S d S # |	                                r)|
                                 |                                 w w xY w)Nz(?<=[({}])(((//[^\n]*)?[\n])([\000-\040])*)*((/[^/\[\n]*(([^\n]|(\[\n]*(]*)*\]))[^/\[]*)*/))((((//[^\n]*)?[\n])([\000-\040]|(/\*[^*]*\*+([^/*]\*+)*/))*)+(?=[^\000-\040);\]}]))zja(function() {
            ///////////////////////////////////////////////////////////////////
        });r   )targetargszpattern.sub() timed out)r:   r<   multiprocessingProcessrF   r?  r   r   r  is_alive	terminate)r   r8   input_jsrW  s       r   test_regression_gh94675zReTests.test_regression_gh94675s	  s    * H I I
 #7;b(^LLL					}	QZZ\\+DEEEzz||  qzz|| s   #(C ?D
r   )r   r   r   r6   rC   rH   rR   rW   ri   rw   r~   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r#  r0  r>  rD  rN  rX  r[  r`  rd  rh  ro  rs  rw  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r:   rL  r  rG   ascii_lettersdigitsr  r  r  r  r  r  r  r	  r  r$  r/  r8  r:  r=  rA  rE  rI  rK  rM  rV  r^  r`  rs  rw  rz  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r  r  r  r  r  r  r   r  r  r  r  r  unittestskipIfr	   r
   r'  r#  r$  r6  r>  r@  rB  rK  rM  rP  r\  r^  rh  rm  rq  rs  ru  rz  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r&   r&   %   s	              / / / // / / /	 	 	E E E
1 
1 
1H H H"" " ")@ )@ )@V% % %
	' 	' 	'A A A, , ,.  .  . `F F F
( ( (@ @ @+H +H +HZ	H 	H 	H01 01 01dK K K3J 3J 3Jj	6 	6 	69 9 94; ; ;N N NBB B B**- *- *-XR R R<@ @ @<&? &? &?P3 3 3
M M MO O O? ? ?
  "H "H "HH3 3 3,N N N@F F F&&N &N &NP9 9 94B B B) ) )# # #B B B8K K K4&= &= &=P$A $A $AL-F -F -F^? ? ?H H H+8 +8 +8ZA A A 04$L) ) ) ) (6=8;LLM
B 
B 
BB B BD D D& & &     + + ++ + +< < <K K K@L L L8F F F*H H H$	G 	G 	GF F F
? ? ?
O 
O 
O3 3 3J J J? ? ?
F 
F 
F: : :/ / /(* * *& & &&, , ,, , ,' ' '24 4 4( ( (
, , ,5 5 54 4 4*D D D:M :M :Mz9 9 99 9 9< < <:+: +: +:Z; ; ;B8 8 8> > >G G G$I I I4 4 4 ZS###( ( $#( ZS(((& & )(&Q Q QU U UI I I
H H H
8 8 80 0 04K K K(2 2 2  $M M M
 X_ 7 $ $	 $$9 9 9; ; ; X_ 7 1 1	 1@"7 "7 "7HF F F+ + +     :4 4 4"* * * 9  9  9DH H H: : :G G G(; ; ;
7 
7 
7" " "     %3 %3 %3N? ? ?6	I 	I 	I8 8 8B B B6	L 	L 	LU U U5 5 50K K K( X__,.MNN  ON  r   r&   c                     t                      5 }t          j        | t          j                   d d d            n# 1 swxY w Y   |                                S r   )r   r:   r<   DEBUGgetvalue)r   outs     r   get_debug_outr  	  s    			 "c

3!!!" " " " " " " " " " " " " " "<<>>s    ;??c                   *    e Zd ZdZd Zd Zd Zd ZdS )
DebugTestsNc                     d}d}|                      t          |          |           |                      t          |          |           d S )Nz(\.)(?:[ch]|py)(?(1)$|: )a  SUBPATTERN 1 0 0
  LITERAL 46
BRANCH
  IN
    LITERAL 99
    LITERAL 104
OR
  LITERAL 112
  LITERAL 121
GROUPREF_EXISTS 1
  AT AT_END
ELSE
  LITERAL 58
  LITERAL 32

 0. INFO 8 0b1 2 5 (to 9)
      prefix_skip 0
      prefix [0x2e] ('.')
      overlap [0]
 9: MARK 0
11. LITERAL 0x2e ('.')
13. MARK 1
15. BRANCH 10 (to 26)
17.   IN 6 (to 24)
19.     LITERAL 0x63 ('c')
21.     LITERAL 0x68 ('h')
23.     FAILURE
24:   JUMP 9 (to 34)
26: branch 7 (to 33)
27.   LITERAL 0x70 ('p')
29.   LITERAL 0x79 ('y')
31.   JUMP 2 (to 34)
33: FAILURE
34: GROUPREF_EXISTS 0 6 (to 41)
37. AT END
39. JUMP 5 (to 45)
41: LITERAL 0x3a (':')
43. LITERAL 0x20 (' ')
45: SUCCESS
r5   r  )r   r   dumps      r   test_debug_flagzDebugTests.test_debug_flag	  sU    *(R 	s++T222 	s++T22222r   c                 L    |                      t          d          d           d S )Nz(?>ab?)zATOMIC_GROUP
  LITERAL 97
  MAX_REPEAT 0 1
    LITERAL 98

 0. INFO 4 0b0 1 2 (to 5)
 5: ATOMIC_GROUP 11 (to 17)
 7.   LITERAL 0x61 ('a')
 9.   REPEAT_ONE 6 0 1 (to 16)
13.     LITERAL 0x62 ('b')
15.     SUCCESS
16:   SUCCESS
17: SUCCESS
r  rh   s    r   test_atomic_groupzDebugTests.test_atomic_group	  s3    z22 5 	 	 	 	 	r   c                 L    |                      t          d          d           d S )Nr  zPOSSESSIVE_REPEAT 0 1
  LITERAL 97

 0. INFO 4 0b0 0 1 (to 5)
 5: POSSESSIVE_REPEAT_ONE 6 0 1 (to 12)
 9.   LITERAL 0x61 ('a')
11.   SUCCESS
12: SUCCESS
r  rh   s    r   test_possesive_repeat_onez$DebugTests.test_possesive_repeat_one	  s3    v.. 	1 		 		 		 		 		r   c                 L    |                      t          d          d           d S )Nr  zPOSSESSIVE_REPEAT 0 1
  LITERAL 97
  LITERAL 98

 0. INFO 4 0b0 0 2 (to 5)
 5: POSSESSIVE_REPEAT 7 0 1 (to 13)
 9.   LITERAL 0x61 ('a')
11.   LITERAL 0x62 ('b')
13: SUCCESS
14. SUCCESS
r  rh   s    r   test_possesive_repeatz DebugTests.test_possesive_repeat	  s3    {33 6 	 	 	 	 	r   )r   r   r   maxDiffr  r  r  r  r   r   r   r  r  	  sV        G.3 .3 .3`  "
 
 
    r   r  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S )PatternReprTestsc                 p    |                      t          t          j        |                    |           d S r   r5   r  r:   r<   )r   r8   r  s      r   checkzPatternReprTests.check	  s0    bj1122H=====r   c                 r    |                      t          t          j        ||                    |           d S r   r  )r   r8   rz  r  s       r   check_flagszPatternReprTests.check_flags	  s2    bj%88998DDDDDr   c                 2    |                      dd           d S )Nr  re.compile('random pattern')r  rh   s    r   test_without_flagsz#PatternReprTests.test_without_flags	  s(    

#1	3 	3 	3 	3 	3r   c                 H    |                      dt          j        d           d S )Nr  z+re.compile('random pattern', re.IGNORECASE))r  r:   r  rh   s    r   test_single_flagz!PatternReprTests.test_single_flag	  s.    )2=9	; 	; 	; 	; 	;r   c                 |    |                      dt          j        t          j        z  t          j        z  d           d S )Nr  z@re.compile('random pattern', re.IGNORECASE|re.DOTALL|re.VERBOSE))r  r:   r   r   r   rh   s    r   test_multiple_flagsz$PatternReprTests.test_multiple_flags	  s<    )249RT>2	3 	3 	3 	3 	3r   c                     |                      dt          j        d           |                      dt          j        t          j        z  t          j        z  d           d S )Nr  r  z5re.compile('random pattern', re.IGNORECASE|re.DOTALL))r  r:   r{  r   r   rh   s    r   test_unicode_flagz"PatternReprTests.test_unicode_flag
  s^    )247	9 	9 	9)249RT>4	5 	5 	5 	5 	5r   c                 2    |                      dd           d S )Nz(?i)patternz(re.compile('(?i)pattern', re.IGNORECASE)r  rh   s    r   r  z"PatternReprTests.test_inline_flags	
  s'    

==	? 	? 	? 	? 	?r   c                 |    |                      ddd           |                      ddt          j        z  d           d S )Nr  i 0 z&re.compile('random pattern', 0x123000)z4re.compile('random pattern', re.IGNORECASE|0x123000))r  r:   r   rh   s    r   test_unknown_flagsz#PatternReprTests.test_unknown_flags
  sZ    )8A	C 	C 	C)8BD=B	D 	D 	D 	D 	Dr   c                 t    |                      dd           |                     dt          j        d           d S )N   bytes patternzre.compile(b'bytes pattern')z&re.compile(b'bytes pattern', re.ASCII))r  r  r:   r   rh   s    r   
test_byteszPatternReprTests.test_bytes
  sO    

#1	3 	3 	3)24A	C 	C 	C 	C 	Cr   c                 H    |                      dt          j        d           d S )Nr  z're.compile(b'bytes pattern', re.LOCALE))r  r:   r  rh   s    r   test_localezPatternReprTests.test_locale
  s3    )24B	D 	D 	D 	D 	Dr   c                     |                      dd           |                      dd           |                      dd           d S )Nzrandom "double quoted" patternz,re.compile('random "double quoted" pattern')zrandom 'single quoted' patternz,re.compile("random 'single quoted' pattern")z!both 'single' and "double" quotesz1re.compile('both \'single\' and "double" quotes')r  rh   s    r   test_quoteszPatternReprTests.test_quotes
  sk    

3>	@ 	@ 	@

3>	@ 	@ 	@

:E	G 	G 	G 	G 	Gr   c                    dddz  z  }t          t          j        |                    }|                     t	          |          d           |                     |d d         d           t          t          j        |t          j                            }|                     t	          |          d           |                     |d d         d           |                     |dd          d           d S )	NzVery %spatternzlong r<  i,     zre.compile('Very long long loniz, re.IGNORECASE))r  r:   r<   ry  rC  r5   r   )r   r8   rM  s      r   test_long_patternz"PatternReprTests.test_long_pattern%
  s    "gn5G$$%%A$$$3B3!ABBBGRT**++A$$$3B3!ABBB344"455555r   c                    |                      t          t          j                  d           |                      t          t          j        t          j        z  t          j        z            d           |                      t          t          j        t          j        z  t          j        z  dz            d           |                      t          t          j                   d           |                      t          t          j        t          j        z  t          j        z             d           |                      t          t          j        t          j        z  t          j        z  dz             d           d S )Nzre.IGNORECASEz"re.IGNORECASE|re.DOTALL|re.VERBOSEi   z+re.IGNORECASE|re.DOTALL|re.VERBOSE|0x100000zTre.ASCII|re.LOCALE|re.UNICODE|re.MULTILINE|re.DOTALL|re.VERBOSE|re.TEMPLATE|re.DEBUGz?re.ASCII|re.LOCALE|re.UNICODE|re.MULTILINE|re.TEMPLATE|re.DEBUGzGre.ASCII|re.LOCALE|re.UNICODE|re.MULTILINE|re.TEMPLATE|re.DEBUG|0xffe00)r5   r  r:   r   r   r   rh   s    r   test_flags_reprz PatternReprTests.test_flags_repr/
  s>   bd_555bd24in--=	? 	? 	?bd24ine455F	H 	H 	HbdUf	h 	h 	h 	RT	"$/00Z	\ 	\ 	\RT	"$ 6788b	d 	d 	d 	d 	dr   N)r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r  r  	  s        > > >E E E3 3 3; ; ;3 3 3
5 5 5? ? ?D D DC C CD D DG G G6 6 6d d d d dr   r  c                       e Zd ZdZed             Zd Zd Zed             Zd Z	ed             Z
ed             Zed	             Zd
S )ImplementationTestz7
    Test implementation details of the re module.
    c                    |                      t                    5  dt          j        _        d d d            n# 1 swxY w Y   |                      t                    5  dt          j        _        d d d            n# 1 swxY w Y   |                      t                    5  t          j        d          }t          |                    d                    }d|_        d d d            d S # 1 swxY w Y   d S )Nr]   r   )	r9   rB  r:   Matchro  r  r<   r.   rd  )r   r   tps      r   test_immutablez!ImplementationTest.test_immutableC
  s    y)) 	 	BHL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	BJN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	*R..Cckk"oo&&BBF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s1   9= =A<<B B !>C,,C03C0c                    t           j        j        }|                      |d          g            |                      |d          dg           |                      |d          g d           |                      |d          g d           |                      |d          g d	           |                      |d
          g d           d S )Nr   rs   r   rI  )r   r   r   r   aaaa)r   r]   rm   r^   ababba)r   r   r]   rm   r   r]   abcabdac)r   r   r   r]   rm   r   r]   r   )r:   	_compiler_generate_overlap_tabler5   )r   fs     r   test_overlap_tablez%ImplementationTest.test_overlap_tableO
  s    L02###3!%%%6LLL1116LLL1118&8&8&8999:(@(@(@AAAAAr   c                     |                      t          j        j        d           |                      t          j        j        d           d S )Nr   )assertGreaterEqualr:   r  	MAXREPEATrb  rh   s    r   test_signednessz"ImplementationTest.test_signednessX
  s>     6::: 6:::::r   c                     t          | t          j                   t          | t          j                   t          j        d          }t          | t          |                    d                               d S )Nr   )r   r:   r  r  r<   r.   rd  r   s     r   test_disallow_instantiationz.ImplementationTest.test_disallow_instantiation\
  s]     	%T28444$T2:666jnn$T4B+@+@AAAAAr   c           	      (   g dg dg dd}|D ]}|                      |          5  t          j                            |d            |                     t
                    5 }t          |           d d d            n# 1 swxY w Y   |                     t          |j	                  d|d           |                     |j
        t                     |                     |t          j                   t          j        |         }|                     |j        |           |                     |j        d           ||         D ]%}|                     t!          ||                     &t          j        |= d d d            n# 1 swxY w Y   d S )	N)r<   r;   SRE_FLAG_IGNORECASE
SUBPATTERN_compile_info)r;   r
  r  _NamedIntConstant)
SubPatternparser
  r  
_parse_sub)sre_compilesre_constants	sre_parse)modulezmodule z is deprecatedr   )r=   sysmodulespopr  r   
__import__r5   r{   r  r   r   r<  r   __package__rv  hasattr)r   
deprecatednamer   rU  attrs         r   test_deprecated_modulesz*ImplementationTest.test_deprecated_modulesd
  s%   - - -3 3 3( ( (	
 	

  	& 	&DT** & &d+++%%&899 %Qt$$$% % % % % % % % % % % % % % %  QY!A4!A!A!AC C C  X666dCK000k$'  t444  "555&t, 8 8DOOGC$6$67777K%& & & & & & & & & & & & & & &	& 	&s6   ;F#A?3F?BFBC2FF		F		c                    dd l }t          d          D ]}t          |          }t          |                                          }|                     |                    |          |           |                     |                    |          |           |t          j	        v }|                     |
                    |          |           |                     |                    |          |           t          t          dd                    ddgz   D ]8}t          |          }|                     |                    |          |           |dk    rH|                     |                    |          t          |                                                     ||                                k    p||                                k    }|                     |
                    |                     |                     |                    |          ||                                k    p||                                k               :|                     |                    d          d           |                     |                    d          t          d                     |                     |
                    d                     |                     |                    d                     d S )Nr   r  i   i  i( i0  r   )_srer   r   ordr  r5   ascii_tolowerunicode_tolowerrG   r  ascii_iscasedunicode_iscasedr+   upperr  rv  )r   r   r   ru   loiscaseds         r   test_case_helpersz$ImplementationTest.test_case_helpers
  s   s 	? 	?AAAQWWYYBT//22B777T11!44b9996//GT//22G<<<T11!44g>>>>eC(())Wg,>> 	? 	?AAAT//22A666F{{  !5!5a!8!8#aggii..III17799n6QWWYYGT//22333T11!44!''))^=qAGGII~? ? ? ? 	++F33V<<<--f55s3xx@@@++F33444,,V4455555r   c           	         dd l }ddz  }|                     t          t          j        di            |                     t
                    5  |                    dd|gdi d           d d d            n# 1 swxY w Y   |                     t                    5  |                    i dg dg g            d d d            d S # 1 swxY w Y   d S )Nr   rm   r  rs   ro   r   )r   r9   rB  r:   rM   r  r<   )r   r   long_overflows      r   test_dealloczImplementationTest.test_dealloc
  sO    	
 3)R[#r:::}-- 	? 	?LLM?Ar2>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?y)) 	/ 	/LLQAr2...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s$   A33A7:A7C  CCc                    	 ddl m} n%# t          $ r |                     d           Y nw xY wddz  }|                     t          j        d|dz
  z  |                     |                     t          j        d|dz
  z  |                                          d	           |                     t          j        d
|dz
  z  |                     | 	                    t          t
          j        d|z             | 	                    t          t
          j        d|z             | 	                    t          t
          j        d
|z             d S )Nr   )r  z requires _sre.MAXREPEAT constantr1   r  r  r]   r  )r   r  r  )r   r  ImportErrorr"  rf   r:   rg   r5   re   r9   r  r<   )r   r  rG   s      r   %test_repeat_minmax_overflow_maxrepeatz8ImplementationTest.test_repeat_minmax_overflow_maxrepeat
  sL   	>&&&&&&& 	> 	> 	>MM<=====	>v"(8y1}#=vFFGGG)y1}"=vFFKKMM$	& 	& 	&"(:Q#?HHIII-X	5IJJJ-Y5JKKK-Z)5KLLLLLs   	 ++N)r   r   r   __doc__r   r  r  r  r  r  r)  r,  r/  r   r   r   r  r  >
  s          	 	 \	B B B; ; ; B B \B& & &6 6 6 \64 / / \/ M M \M M Mr   r  c                       e Zd Zd Zd ZdS )ExternalTestsc                 B   ddl m} |D ]\  }}|                     ||          5  t          j        |          }|                     |                    |                     |                     |                    |                     |                     |                    |                     ddz  |z   ddz  z   }|                     |                    |                     |                     |                    |d                     |                     |                    |ddt          |          z                        |                     |                    |ddt          |          z                        ddd           n# 1 swxY w Y   dS )zre_tests benchmarksr   )
benchmarksr8   rG   rq  r  N)
test.re_testsr4  r=   r:   r<   rv  rd   rg   rL  rC  )r   r4  r8   rV   rW  s2s         r   test_re_benchmarksz ExternalTests.test_re_benchmarks
  s   ,,,,,,$ 
	H 
	HJGQga88 	H 	HJw'',,,

+++A///Y]SY.---E 2 2333E53q66> B BCCCBus1vv~ F FGGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H
	H 
	Hs   E FF	F	c                 *
   ddl m}m}m} |D ]}dx}x}x}x}}	t	          |          dk    r	|\  }}}}}	n*t	          |          dk    r|\  }}}nt          d|          |                     ||          5  ||k    rX|                     t          j	                  5  t          j
        |           ddd           n# 1 swxY w Y   	 ddd           t          j
        |          }
|
                    |          }||k    r$|                     |d           	 ddd           |                                 5  |                     |d	           |                    d          \  }}|                    d          |                                |j        j        d
}t#          dd          D ]7}	 |                    |          }|d}n# t$          $ r d}Y nw xY w||d|z  <   8|j        j                                        D ]4}	 |                    |          }|d}n# t$          $ r d}Y nw xY w|||<   5|                     t-          ||          |	d           ddd           n# 1 swxY w Y   	 t/          |d          }t/          |d          }|                     d          5  t          j
        |          }
|                     |
                    |                     ddd           n# 1 swxY w Y   |                     d          5  t          j
        |t          j                  }
|
                    |          }|t3          d|           ddd           n# 1 swxY w Y   n# t4          $ r Y nw xY w|dd         dk    r~|dd         dk    rp|n|                     d          5  t          j
        |          }
|                     |
                    |||dz                        ddd           n# 1 swxY w Y   |                     d          5  t          j
        |t          j                  }
|                     |
                    |                     ddd           n# 1 swxY w Y   |                     d          5  t          j
        |t          j                  }
|                     |
                    |                     ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   dS )zre_tests test suiter   )testsFAILSYNTAX_ERRORNr   r^   z%Test tuples should have 3 or 5 fieldsr5  zSucceeded incorrectlyzFailed incorrectly)foundr/  rz  r]   d   Noner!  zg%dzgrouping errorr  zbytes pattern matchzlocale-sensitive matchz#=== Fails on locale-sensitive matchrm   r  zrange-limited matchzcase-insensitive matchzunicode-sensitive match)r6  r:  r;  r<  rC  r   r=   r9   r:   r;   r<   rd   rf   rv  re   rz   rz  r   r   r|  keysr5   evalr  r  printUnicodeEncodeErrorr  r  )r   r:  r;  r<  re  r8   rV   outcomerE   r  objresultr?  r@  vardictr   gir  bss                      r   test_re_testszExternalTests.test_re_tests
  s   ;;;;;;;;;; Z	3 Z	3A6::G:a:':D81vv{{673GT88Q1&'#GG !H!LLLga88 Q3 Q3l****2844 , ,
7+++, , , , , , , , , , , , , , ,	Q3 Q3 Q3 Q3 Q3 Q3 Q3 j))Ad??%%f.EFFFQ3 Q3 Q3 Q3 Q3 Q3 Q3 \\^^ 7 7OOF,@AAA "(QJE3(.Q)/(.	9 9G #1c]] 0 0)!'aB!z%+) ) ) )!(BBB)-/	**#Y16688 ( ()!'aB!z%+) ) ) )!(BBB)%'

$$T$%8%8(%57 7 737 7 7 7 7 7 7 7 7 7 7 7 7 7 7<L '22Dq'**B
 &;<< 8 8 j..

27778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 &>?? L L jry99!$B!>!"GKKK	L L L L L L L L L L L L L L L *   D( BQBK5((WRSS\U-B-B & 2&;<< G G j11

1eS1W(E(EFFFG G G G G G G G G G G G G G G \\":;; 3 3*Wbm<<COOCJJqMM2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 \\";<< 3 3*Wbj99COOCJJqMM2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3_Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3 Q3Z	3 Z	3s  7&TB>2T>CTCTAT)T=A6I-4GI-GI-G,I-
H$#I-$H30I-2H33.I-!T-I11T4I15T9 M6T.=K7+T7K;;T>K;?TAM*T*M..T1M.2T6
N TN6T9AP;TPTPT'AQ;/T;Q??TQ?TAS/#T/S33T6S37TT
	T
	N)r   r   r   r8  rK  r   r   r   r2  r2  
  s:        H H H]3 ]3 ]3 ]3 ]3r   r2  __main__)$test.supportr   r   r   r   r   r   r	   r
   r   r  r:   rG   r  rw  r  r  r   weakrefr   _multiprocessingr  r.  r{   r   r  r#   TestCaser&   r  r  r  r  r2  r   mainr   r   r   <module>rR     s  ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )  				  



                    OOO- - - - - - - -- - - - - - - -`% `% `% `% `%h `% `% `%FK   \ \ \ \ \" \ \ \~Md Md Md Md Mdx( Md Md Md`xM xM xM xM xM* xM xM xMvn3 n3 n3 n3 n3H% n3 n3 n3b zHMOOOOO s    A	 	AA