σ
\K]c           @`  s5  d  d l  m Z m Z d  d l Z d  d l Z d  d l m Z d  d l m Z m	 Z	 d  d l m
 Z
 m Z d  d l m Z y d  d l Z Wn e k
 r£ d Z n Xy d  d l Z Wn e k
 rΝ d Z n Xe j e d k d  d e j f d	     Y Z d
 e j f d     YZ e d k r1e j   n  d S(   i    (   t   absolute_importt   divisionN(   t   unittest_support(   t   compile_isolatedt   Flags(   t   typest   utils(   t   StringIOs#   please install the 'jinja2' packaget   TestAnnotationc           B`  sD   e  Z d    Z d   Z d   Z e j e d k d  d    Z	 RS(   c         C`  sm   d   } t  | t j t j g  } | j } t   } | j |  | j   } | j   |  j d |  d S(   s4   
        Ensures template.html is available
        c         S`  s+   | } x t  |   D] } | | 7} q W| S(   N(   t   range(   t   nt   at   st   i(    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt   foo   s    R   N(	   R   R   t   int32t   type_annotationR   t   html_annotatet   getvaluet   closet   assertIn(   t   selfR   t   crest   tat   buft   output(    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt   test_exercise_code_path   s    			
c         `  sΏ   d       f d   } t    } | j d  | j d  t | t j g d | } | j } t   } | j |  | j   } | j	   |  j
 d |  |  j
 d |  |  j
 d |  d	 S(
   sM   
        Ensures that lifted loops are handled correctly in obj mode
        c         S`  s   |  S(   N(    (   t   x(    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt   bar1   s    c         `  sD   d } x t  |   D] } | | } q W|  r@ |   |   } n  | S(   Ng        (   R	   (   R   t   ht   k(   R   (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyR   4   s    t   enable_pyobjectt   enable_loopliftt   flagsR   R   t
   LiftedLoopN(   R   t   setR   R   t   intpR   R   R   R   R   R   (   R   R   R!   R   R   R   R   (    (   R   s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt(   test_exercise_code_path_with_lifted_loop,   s    					
c   	      C`  sΗ  t  j d    } t j d t j  } t j f } | j |  | j | } t   } | j	 j
 |  | j   } | j   |  j | j d  d  d } |  j | j | j |   d  |  j t t j | |   d d d | | f t j f } | j |  | j | } t   } | j	 j
 |  | j   } | j   |  j | j d  d  |  j | j | j |   d  |  j | j | j |   d  |  j t t j | |   d  d	 S(
   sW   
        Test some format and behavior of the html annotation with lifted loop
        c         S`  s2   t    d } x t |   D] } | | 7} q W| S(   Ni    (   t   objectR	   (   R   t   zR   (    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt   udtP   s
    s   <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*s   Function name: udti   s!   with signature: {} -&gt; pyobjectt   msgs   %s not found in %si   N(   t   numbat   jitt   ret   compilet	   MULTILINER   t   int64t	   overloadsR   R   R   R   R   t   assertEqualt   countt   formatt   lent   findallt   float64(	   R   R(   t   re_lifted_tagt   sig_i64R   R   R   t   sigfmtt   sig_f64(    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt!   test_html_output_with_lifted_loopL   s6    		
"!	
""s%   please install the 'pygments' packagec      	   C`  s~   t  j d    } | d d  | j d t  } |  j t   } | j d t d d  } Wd  QX|  j d t | j   d  S(   Nc         S`  s
   |  | f S(   N(    (   R   t   y(    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyR      s    i   i   t   prettyt   files   should be Nones$   `file` must be None if `pretty=True`(	   R*   t   njitt   inspect_typest   Truet   assertRaisest
   ValueErrorR   t   strt	   exception(   R   R   t   objt   raises(    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt   test_pretty_print   s    N(
   t   __name__t
   __module__R   R%   R;   t   unittestt   skipIft   pygmentst   NoneRH   (    (    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyR      s   		 	<t   TestTypeAnnotationc           B`  s   e  Z d    Z RS(   c         `  s­   t  j d    } | d d  t j   } | j |  | j   j       f d   } | d  } | d  } | d  } | d  } |  j | |  |  j | |  d  S(	   Nc         S`  s   |  | S(   N(    (   t   appleoranget   berrycherry(    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyR      s    i   i   c         `  sF   x* t     D] \ } } |  | k r | Sq Wt d j |     d  S(   Ns   can't find {!r}(   t	   enumerateRC   R3   (   t   patR   t   ln(   t   lines(    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt
   findpatloc¦   s    s&   appleorange = arg(0, name=appleorange)s&   berrycherry = arg(1, name=berrycherry)s   del appleoranges   del berrycherry(   R*   R?   R   R   R@   R   t
   splitlinest
   assertLess(   R   R   t   strbufRV   t   sat   sbt   eat   eb(    (   RU   s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt   test_delete   s    (   RI   RJ   R^   (    (    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyRO      s   t   __main__(   t
   __future__R    R   R,   R*   R   RK   t   numba.compilerR   R   R   R   t   numba.io_supportR   t   jinja2t   ImportErrorRN   RM   RL   t   TestCaseR   RO   RI   t   main(    (    (    s;   lib/python2.7/site-packages/numba/tests/test_annotations.pyt   <module>   s&   

