
Y]c           @   sK  d  d l  Z e j j d d e Z d  d l m 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 Z d	 e f d
     YZ d e j f d     YZ e j j e j j e j j f Z d d d     YZ d \ Z Z d \ Z Z g  e e d  e d d   D] \ Z Z  e e  f ^ q$Z! e! d e! d d !i d d 6Z i  Z d   e e d  e d d   D Z d   e d  D Z" d h Z" d  Z# d! Z# g  Z! d d g Z! e! rn e e Z Z y	 e$ GHWn d Z$ n Xe$ d 7Z$ z e e 7Z Wd d Z Xd  d l% Td   Z& e' d k rGe&   n  d S("   iNt   compilert
   deprecated(   t   flatten(   t   random(   t   StringIOi   i<   t   TrivialContextc           B   s   e  Z d    Z d   Z RS(   c         C   s   |  S(   N(    (   t   self(    (    s#   lib/python2.7/test/test_compiler.pyt	   __enter__   s    c         G   s   d  S(   N(    (   R   t   exc_info(    (    s#   lib/python2.7/test/test_compiler.pyt   __exit__   s    (   t   __name__t
   __module__R   R	   (    (    (    s#   lib/python2.7/test/test_compiler.pyR      s   	t   CompilerTestc           B   s   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s  t  j    t } t j j t j  } t j j } xz| g D]o} xfd D]^} | t  j    k r t  j    t } t	 j
 d IJt	 j
 j   n  | j d  s qH n  t r t   d k  r qH n  t j j | |  } t j j r d G| GHn  t | d  } | j   } | j   d | k s(d | k rG|  j t t j | | d	  qH y t j | | d	  WqH t k
 r}	 t |	 j  }
 |
 j d
 |  t |
  |	 _   qH XqH Wq; Wd  S(   Ns
   test_os.pys1     testCompileLibrary still working, be patient...s   .pyg\(\?t	   compilingt   Ut	   badsyntaxt
   bad_codingt   execs   in file %s](   s
   test_os.py(   t   timet   _PRINT_WORKING_MSG_INTERVALt   ost   patht   dirnamet   __file__t   testt   test_supportt   TEST_HOME_DIRt   syst
   __stdout__t   flusht   endswitht   TEST_ALLR   t   joint   verboset   opent   readt   closet   assertRaisest   SyntaxErrorR    t   compilet	   Exceptiont   listt   argst   appendt   tuple(   R   t	   next_timet   libdirt   testdirt   dirt   basenameR   t   ft   buft   eR*   (    (    s#   lib/python2.7/test/test_compiler.pyt   testCompileLibrary   s<    
c         C   s   t  j d d d  d  S(   Ns   class foo():pass

s   <string>R   (   R    R'   (   R   (    (    s#   lib/python2.7/test/test_compiler.pyt   testNewClassSyntax?   s    c         C   s   t  j d d d  d  S(   Ns   def g(): yield

s   <string>R   (   R    R'   (   R   (    (    s#   lib/python2.7/test/test_compiler.pyt   testYieldExprB   s    c            sc     f d   } e  j d d d  } | i | d 6U  j e e  j d    j e e  j d  d  S(   Nc             s.     j  |  | f d i d d 6d d 6f  d  S(   Ni   i   i   t   xi   t   y(   i   i   (   t   assertEqual(   R*   t   kwargs(   R   (    s#   lib/python2.7/test/test_compiler.pyR2   F   s    s   f(x=1, *(2, 3), y=4)s   <string>R   R2   s   foo(a=1, b)s   foo(1, *args, 3)(   R    R'   R%   R&   t   parse(   R   R2   t   c(    (   R   s#   lib/python2.7/test/test_compiler.pyt   testKeywordAfterStarargsE   s
    c         B   sY   e  j d d d  } i  } | | U|  j | j d  d  |  j | j d  d  d  S(   Ns)   try:
 1//0
except:
 e = 1
finally:
 f = 1s   <string>R   R4   i   R2   (   R    R'   R:   t   get(   R   R=   t   dct(    (    s#   lib/python2.7/test/test_compiler.pyt   testTryExceptFinallyN   s    	c         C   s   |  j  t t j d  d  S(   Ns   def foo(a=1, b): pass(   R%   R&   R    R<   (   R   (    (    s#   lib/python2.7/test/test_compiler.pyt   testDefaultArgsW   s    c         B   sf   e  j d d d  } |  j d | j  e  j d d d  } i  } | | U|  j | d j d  d  S(   Ns   "doc"s   <string>R   t   __doc__s   def f():
 "doc"R2   t   doc(   R    R'   t   assertInt   co_namesR:   RC   (   R   R=   t   g(    (    s#   lib/python2.7/test/test_compiler.pyt   testDocstringsZ   s    c         C   sB   t  } | j d  r" | d  } n  t j |  } |  j |  d  S(   Ns   .pycs   .pyoi(   s   .pycs   .pyo(   R   R   R    t	   parseFilet   check_lineno(   R   t   filenamet   tree(    (    s#   lib/python2.7/test/test_compiler.pyt
   testLineNob   s
    c         C   s;   y |  j  |  Wn# t k
 r6 | j G| j GH  n Xd  S(   N(   t   _check_linenot   AssertionErrort	   __class__t   lineno(   R   t   node(    (    s#   lib/python2.7/test/test_compiler.pyRJ   j   s
    c         C   s   | j  t k ra |  j | j t d | j | j  f  |  j | j d k d | j | j  f  n  x! | j   D] } |  j |  qn Wd  S(   Ns   lineno=%s on %si    (   RP   t   NOLINENOt   assertIsInstanceRQ   t   intt
   assertTruet   getChildNodesRJ   (   R   RR   t   child(    (    s#   lib/python2.7/test/test_compiler.pyRN   q   s    c         C   sK   |  j  t d d g g  d d g  |  j  t d d f  d d g  d  S(   Ni   i   (   i   (   R:   R   (   R   (    (    s#   lib/python2.7/test/test_compiler.pyt   testFlattenz   s    %c         B   s@   e  j d d d  } i  } | | U|  j | j d  d  d  S(   NsH   def g():
    a = 1
    def f(): return a + 2
    return f()
result = g()s   <string>R   t   resulti   (   R    R'   R:   R?   (   R   R=   R@   (    (    s#   lib/python2.7/test/test_compiler.pyt   testNestedScope~   s    		c         C   s8   t  j d d d  } |  j t |  d d	 d
 g  d  S(   NsK   list((i,j) for i in range(3) if i < 3           for j in range(4) if j > 2)s   <string>t   evali    i   i   i   (   i    i   (   i   i   (   i   i   (   R    R'   R:   R\   (   R   R=   (    (    s#   lib/python2.7/test/test_compiler.pyt
   testGenExp   s    		c         C   sl   t  j d d d  } |  j t |  d d d h  t  j d d d  } |  j t |  d d d h  d  S(   Ns	   {1, 2, 3}s   <string>R\   i   i   i   s
   {1, 2, 3,}(   R    R'   R:   R\   (   R   R=   (    (    s#   lib/python2.7/test/test_compiler.pyt   testSetLiteral   s    c         C   s   t  j d d d  } |  j t |  i d d 6d d 6d d 6 t  j d d d  } |  j t |  i d d 6d d 6d d 6 d  S(	   Ns   {1:2, 2:3, 3:4}s   <string>R\   i   i   i   i   s   {1:2, 2:3, 3:4,}(   R    R'   R:   R\   (   R   R=   (    (    s#   lib/python2.7/test/test_compiler.pyt   testDictLiteral   s    +c         C   sr   t  j d d d  } |  j t |  d d d h  t  j d d d  } |  j t |  d d d d d	 h  d  S(
   Ns   {x for x in range(1, 4)}s   <string>R\   i   i   i   sE   {x * y for x in range(3) if x != 0       for y in range(4) if y != 0}i   i   (   R    R'   R:   R\   (   R   R=   (    (    s#   lib/python2.7/test/test_compiler.pyt   testSetComp   s    		c         C   s}   t  j d d d  } |  j t |  i d d 6d d 6d d 6 t  j d d d  } |  j t |  i d d	 6d d
 6 d  S(   Ns   {x:x+1 for x in range(1, 4)}s   <string>R\   i   i   i   i   sO   {(x, y) : y for x in range(2) if x != 0            for y in range(3) if y != 0}(   i   i   (   i   i   (   R    R'   R:   R\   (   R   R=   (    (    s#   lib/python2.7/test/test_compiler.pyt   testDictComp   s    +		c         B   sG   e  j d d d  } i e d 6} | | U|  j | j d  d  d  S(   Nsg   from __future__ import with_statement
def f():
    with TrivialContext():
        return 1
result = f()s   <string>R   R   RZ   i   (   R    R'   R   R:   R?   (   R   R=   R@   (    (    s#   lib/python2.7/test/test_compiler.pyt   testWith   s    		c         B   sG   e  j d d d  } i e d 6} | | U|  j | j d  d  d  S(   Nsm   from __future__ import with_statement
def f():
    with TrivialContext() as tc:
        return 1
result = f()s   <string>R   R   RZ   i   (   R    R'   R   R:   R?   (   R   R=   R@   (    (    s#   lib/python2.7/test/test_compiler.pyt   testWithAss   s    		c            s|   g    d d	   f d     Y} e  j d d d  } i | d 6} | | U|  j | j d  d  |  j   d d g  d  S(
   Nt   Ctxc              s)   e  Z d    Z   f d   Z d   Z RS(   c         S   s   | |  _  d  S(   N(   t   n(   R   Re   (    (    s#   lib/python2.7/test/test_compiler.pyt   __init__   s    c            s     j  |  j  d  S(   N(   R+   Re   (   R   (   t   events(    s#   lib/python2.7/test/test_compiler.pyR      s    c         W   s   d  S(   N(    (   R   R*   (    (    s#   lib/python2.7/test/test_compiler.pyR	      s    (   R
   R   Rf   R   R	   (    (   Rg   (    s#   lib/python2.7/test/test_compiler.pyRd      s   	sr   from __future__ import with_statement
def f():
    with Ctx(1) as tc, Ctx(2) as tc2:
        return 1
result = f()s   <string>R   RZ   i   i   (    (   R    R'   R:   R?   (   R   Rd   R=   R@   (    (   Rg   s#   lib/python2.7/test/test_compiler.pyt   testWithMult   s    		c         B   sO   e  j d d d  } i i  d 6} i  } | | | U|  j | j d  d  d  S(   Ns   global x
x=1s   <string>R   t   __builtins__R8   i   (   R    R'   R:   R?   (   R   t   codet   d1t   d2(    (    s#   lib/python2.7/test/test_compiler.pyt
   testGlobal   s
    
c         B   sK   e  j d d d  } i e   d 6} | | U|  j | d j   d  d  S(   NsV   from __future__ import print_function
print("a", "b", sep="**", end="++", file=output)s   <string>R   t   outputs   a**b++(   R    R'   R   R:   t   getvalue(   R   R=   R@   (    (    s#   lib/python2.7/test/test_compiler.pyt   testPrintFunction   s    		c         C   sT   y t  | d d  Wn9 t k
 rO } |  j | j |  |  j | j |  n Xd  S(   Nt    R   (   R'   R&   R:   t   offsett   text(   R   t   srcRs   Rr   R4   (    (    s#   lib/python2.7/test/test_compiler.pyt   _testErrEnc   s
    c         C   sj   d } d } d } |  j  | | d  |  j  | | | d  |  j  | | | d  |  j  | | d  d  S(   Ns   print 'pC\', '
s   print '12345678', '
s   #! -*- coding: ShiftJIS -*-
i   (   Ru   (   R   t   sjist   asciit   encdef(    (    s#   lib/python2.7/test/test_compiler.pyt   testSourceCodeEncodingsError   s    (   R
   R   R5   R6   R7   R>   RA   RB   RH   RM   RJ   RN   RY   R[   R]   R^   R_   R`   Ra   Rb   Rc   Rh   Rm   Rp   Ru   Ry   (    (    (    s#   lib/python2.7/test/test_compiler.pyR      s0   	,																										
	t   Totoc           B   s   e  Z d  Z RS(   t	   docstring(   R
   R   RC   (    (    (    s#   lib/python2.7/test/test_compiler.pyRz     s   i   i   i   i
   i    i   t   ac         C   s   i  |  ] \ } } | |  q S(    (    (   t   .0R8   R9   (    (    s#   lib/python2.7/test/test_compiler.pys
   <dictcomp>  s   	 c         C   s   h  |  ] } |  q S(    (    (   R}   R8   (    (    s#   lib/python2.7/test/test_compiler.pys	   <setcomp>  s   	 i   (   t   *c           C   s&   t  j j d  a t  j j t  d  S(   Nt   cpu(   R   R   t   is_resource_enabledR   t   run_unittestR   (    (    (    s#   lib/python2.7/test/test_compiler.pyt	   test_main7  s    t   __main__i,  (    (   i   i   (   i   i   (    (   i   i   ((   t   test.test_supportR   R   t   import_modulet   TrueR    t   compiler.astR   R   R   R   t   unittestR   R   R   t   objectR   t   TestCaseR   t   astt   Modulet   Stmtt   DiscardRS   Rz   R|   t   bR=   t   dt   zipt   rangeR8   R9   t   lt   st   tt   yot   mathR   R
   (    (    (    s#   lib/python2.7/test/test_compiler.pyt   <module>   sN   0!=(		


	