
    sht                     @   S SK r S SKJr  S SKrS SKJr  S SKJrJr  S SKJ	r	J
r
  S SKr S SKr S SKr\R                  " \SL S5       " S S\
5      5       r " S	 S
\R                  5      r\S:X  a  \R&                  " 5         gg! \ a    Sr N`f = f! \ a    Sr Nif = f)    N)StringIO)types)jitnjit)override_configTestCasez#please install the 'jinja2' packagec                       \ rS rSr\R
                  S 5       r\R
                  S 5       r\R
                  S 5       r\	R                  " \SL S5      S 5       rSrg)	TestAnnotation   c                 R   S n[        [        R                  [        R                  45      " U5      nUR                  UR                  S      nUR
                  n[        5       nUR                  U5        UR                  5       nUR                  5         U R                  SU5        g)z$
Ensures template.html is available
c                 6    Un[        U 5       H  nX#-  nM	     U$ Nrange)nasis       p/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/tests/test_annotations.pyfoo3TestAnnotation.test_exercise_code_path.<locals>.foo   s!    A1X H    r   r   N)r   r   int32	overloads
signaturestype_annotationr   html_annotategetvaluecloseassertIn)selfr   cfunccrestabufoutputs          r   test_exercise_code_path&TestAnnotation.test_exercise_code_path   s    	 ekk5;;/05u//23!!j
		eV$r   c                   ^ S mU4S jn[        [        R                  4SSS9" U5      nUR                  UR                  S      nUR
                  n[        5       nUR                  U5        UR                  5       nUR                  5         U R                  SU5        U R                  SU5        U R                  SU5        g	)
z=
Ensures that lifted loops are handled correctly in obj mode
c                     U $ r    )xs    r   barDTestAnnotation.test_exercise_code_path_with_lifted_loop.<locals>.bar4   s    Hr   c                    > Sn[        U 5       H  nX-   nM	     [        U 5       H  nX-   nM	     U (       a  UT" U 5      -
  nU$ )Ng        r   )r,   hr   kr-   s       r   r   DTestAnnotation.test_exercise_code_path_with_lifted_loop.<locals>.foo7   sG    A1XE 1XE AJHr   T)forceobjloopliftr   r-   r   
LiftedLoopN)r   r   intpr   r   r   r   r   r   r   r    )r!   r   r"   r#   r$   r%   r&   r-   s          @r   (test_exercise_code_path_with_lifted_loop7TestAnnotation.test_exercise_code_path_with_lifted_loop.   s    		 UZZMD4@Eu//23!!j
		eV$eV$lF+r   c                    [         R                  " SS9S 5       n[        R                  " S[        R                  5      n[
        R                  4nUR                  U5        UR                  U   n[        5       nUR                  R                  U5        UR                  5       nUR                  5         U R                  UR                  S5      S5        SnU R                  UR                  UR                  U5      5      S5        U R                  [!        [        R"                  " X&5      5      SU< SU< 3S	9  [
        R$                  4nUR                  U5        UR                  U   n[        5       nUR                  R                  U5        UR                  5       nUR                  5         U R                  UR                  S5      S
5        U R                  UR                  UR                  U5      5      S5        U R                  UR                  UR                  U5      5      S5        U R                  [!        [        R"                  " X&5      5      S
5        g)zG
Test some format and behavior of the html annotation with lifted loop
T)r3   c                 J    [        5         Sn[        U 5       H  nX-  nM	     U$ )Nr   )objectr   )r,   zr   s      r   udt=TestAnnotation.test_html_output_with_lifted_loop.<locals>.udtT   s&    HA1X Hr   z<td class="lifted_tag">\s*\s*<details>\s*<summary>\s*<code>\s*[0-9]+:\s*[&nbsp;]+for i in range\(x\):  # this line is tagged\s*zFunction name: udt   z!with signature: {} -&gt; pyobjectz not found in )msg   N)numbar   recompile	MULTILINEr   int64r   r   r   r   r   r   assertEqualcountformatlenfindallfloat64)	r!   r=   re_lifted_tagsig_i64r#   r%   r&   sigfmtsig_f64s	            r   !test_html_output_with_lifted_loop0TestAnnotation.test_html_output_with_lifted_loopO   s   
 
D	!	 
"	 

J LL ;;.G}}W% j**3/		 	&:;Q?4fmmG&<=qARZZ>?5BFK 	 	M =="G}}W% j**3/		 	&:;Q?fmmG&<=qAfmmG&<=qARZZ>?Cr   Nz%please install the 'pygments' packagec                 (   [         R                  S 5       nU" SS5        UR                  SS9  U R                  [        5       nUR                  SSS9  S S S 5        U R                  S[        WR                  5      5        g ! , (       d  f       N4= f)	Nc                     X4$ r   r+   )r,   ys     r   r   -TestAnnotation.test_pretty_print.<locals>.foo   s	    4Kr   r?   rA   T)prettyzshould be None)rW   filez$`file` must be None if `pretty=True`)rB   r   inspect_typesassertRaises
ValueErrorr    str	exception)r!   r   raisess      r   test_pretty_print TestAnnotation.test_pretty_print   s     
	 
	 	Aq	& z*fT0@A +<&**+	- +*s   B
Br+   )__name__
__module____qualname____firstlineno__r   run_test_in_subprocessr'   r7   rQ   unittestskipIfpygmentsr_   __static_attributes__r+   r   r   r
   r
      sz     $$% %%* $$, %,@ $$:D %:Dx __X%'NO- P-r   r
   c                   8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
TestTypeAnnotation   c                 p    [        U5       H  u  p4X$;   d  M  Us  $    [        SR                  U5      5      e)Nzcan't find {!r})	enumerater[   rI   )r!   linespatr   lns        r   
findpatlocTestTypeAnnotation.findpatloc   s6    u%EAy & *11#677r   c                 t    [        5       nUR                  U5        UR                  5       R                  5       $ r   )r   rY   r   
splitlines)r!   funcstrbufs      r   getlinesTestTypeAnnotation.getlines   s-    6" ++--r   c                 8   [         R                  S 5       nU" SS5        U R                  U5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  X55        U R	                  XF5        g )Nc                 
    X-   $ r   r+   )appleorangeberrycherrys     r   r   +TestTypeAnnotation.test_delete.<locals>.foo   s    ,,r   r?   rA   z&appleorange = arg(0, name=appleorange)z&berrycherry = arg(1, name=berrycherry)zdel appleorangezdel berrycherry)rB   r   rx   rr   
assertLess)r!   r   ro   sasbeaebs          r   test_deleteTestTypeAnnotation.test_delete   s    		- 
	- 	Aq	c" __U$LM__U$LM__U$56__U$56r   c                 |   [        SU5         [        S 5       nSnU" U5      nU R                  XC5        S S S 5        U R                  W5      nU R	                  US5      nU R	                  US5      nU R	                  US5      nU R	                  US5      n	U R	                  US5      n
XgXU
4$ ! , (       d  f       N~= f)	NEXTEND_VARIABLE_LIFETIMESc                 
    U nU$ r   r+   )r   bs     r   r   /TestTypeAnnotation._lifetimes_impl.<locals>.foo   s    r   
   za = arg(0, name=a)zb = azcast(value=b)zdel azdel b)r   r   rG   rx   rr   )r!   extendr   r,   r   ro   r   r   cast_retdeladelbs              r   _lifetimes_impl"TestTypeAnnotation._lifetimes_impl   s    8&A  AAAQ" B c"__U$89__UG,??5/:ug.ug.xt++' BAs   (B--
B;c                     U R                  SS9u  pp4nU R                  X5        U R                  X%5        U R                  XC5        U R                  XS5        g )Nr   r   r   r   assertGreaterr!   r   r   r   r   r   s         r   test_delete_standard_lifetimes1TestTypeAnnotation.test_delete_standard_lifetimes   sP     (,';';1';'E$!!'4*r   c                     U R                  SS9u  pp4nU R                  X5        U R                  X%5        U R                  XC5        U R                  XS5        g )Nr?   r   r   r   s         r   test_delete_extended_lifetimes1TestTypeAnnotation.test_delete_extended_lifetimes   sR     (,';';1';'E$!!4*4*r   r+   N)ra   rb   rc   rd   rr   rx   r   r   r   r   ri   r+   r   r   rk   rk      s     8.
 &,,+&+r   rk   __main__)rC   ior   rB   
numba.corer   r   r   numba.tests.supportr   r   rf   jinja2ImportErrorrh   rg   r
   rk   ra   mainr+   r   r   <module>r      s    	     9 
 
4!FGE-X E- HE-PZ+** Z+z zMMO _  F
  Hs"   B B BBBB