Ñò
à"Ic           @   s¨   d  Z  d d k Z d d k l Z l Z d d k l Z l Z e o% d d k Z d d k	 Z	 d „  Z
 n d e i f d „  ƒ  YZ d „  Z e d	 j o e ƒ  n d S(
   s/   
   Test cases for codeop.py
   Nick Mathewson
iÿÿÿÿN(   t   run_unittestt	   is_jython(   t   compile_commandt   PyCF_DONT_IMPLY_DEDENTc         C   s<   x5 |  i  ƒ  D]' \ } } t | ƒ o t |  | <q q W|  S(   N(   t   itemst   callable(   t   dt   nt   v(    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt   unify_callables   s
     t   CodeopTestsc           B   sS   e  Z d  d „ Z d  d „ Z d  d d „ Z d „  Z d „  Z d „  Z d „  Z RS(	   t   singlec   	      B   s(  e  oì e | d | ƒ } |  i | ƒ | d j oV h  h  } } e i } e i ƒ  e _ z  | | Ue | d d ƒ | UWd | e _ XnK | d j o= h d d 6} h e | | ƒ d 6} h e | | ƒ d 6} n |  i	 e
 | ƒ e
 | ƒ ƒ n2 e | d | e ƒ } |  i	 e | d | ƒ | ƒ d S(   s(   succeed iff str is a valid piece of codes   <input>R   Nt   evali   t   at   value(   R   R   t   assert_t   syst   stdoutt	   cStringIOt   StringIOt   compileR   t   assertEqualsR	   R   (	   t   selft   strt   symbolt   codeR   t   rt   saved_stdoutt   ctxt   expected(    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt   assertValid   s$    	 c         C   s    |  i  t | d | ƒd ƒ d S(   s5   succeed iff str is the start of a valid piece of codeR   N(   R   R   t   None(   R   R   R   (    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt   assertIncomplete-   s    i   c         C   sh   y! t  | d | ƒ|  i d ƒ Wn@ t j
 o |  i | ƒ n" t j
 o |  i | ƒ n Xd S(   s8   succeed iff str is the start of an invalid piece of codeR   s$   No exception thrown for invalid codeN(   R   t   failt   SyntaxErrorR   t   OverflowError(   R   R   R   t	   is_syntax(    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt   assertInvalid1   s    c         C   s™  |  i  } t pN |  i t d ƒ t d d d t ƒ ƒ |  i t d ƒ t d d d t ƒ ƒ n | 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("   Nt    t   passs   <input>R   s   
s   a = 1s   
a = 1s   a = 1
s   a = 1

s	   

a = 1

s   def x():
  pass
s   if 1:
 pass
s   

if 1: pass
s   

if 1: pass

s   def x():

 pass
s   def x():
  pass
  
s   def x():
  pass
 
s   pass
s   3**3
s   if 9==3:
   pass
else:
   pass
s(   if 1:
 pass
 if 1:
  pass
 else:
  pass
s   #a
#b
a = 3
s   #a

   
a=3
s   a=3

s
   a = 9+ \
3s   3**3R   s   (lambda z: 
 z**3)s   9+ \
3s   9+ \
3
s   

a**3s   
 
a**3s
   #a
#b
a**3(   R   R   R   R   R   R   (   R   t   av(    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt
   test_valid;   sJ    	






















c         C   sb  |  i  } | 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(!   Ns   (a **s   (a,b,s   (a,b,(s   a = (s   a = {s   b + {s   if 9==3:
   pass
else:s   if 9==3:
   pass
else:
s   if 9==3:
   pass
else:
   passs   if 1:s   if 1:
s    if 1:
 pass
 if 1:
  pass
 else:s!   if 1:
 pass
 if 1:
  pass
 else:
s'   if 1:
 pass
 if 1:
  pass
 else:
  passs   def x():s	   def x():
s
   def x():

s   def x():
  passs   def x():
  pass
 s   def x():
  pass
  s   

def x():
  passs   a = 9+ \s   a = 'a\s	   a = '''xyR&   R   s   
t   (s   (


s   (9+s   9+ \s   lambda z: \(   R    (   R   t   ai(    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt   test_incompleteo   sB    	
























c         C   sã   |  i  } | 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(   Ns   a bs   a @s   a b @s   a ** @s   a = s   a = 9 +s   def x():

pass
s   

 if 1: pass

passs	   a = 9+ \
s   a = 'a\ s   a = 'a\
s   a = 1R   s   a = (t   ]s   ())s   [}s   9+s	   lambda z:(   R%   (   R   R+   (    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt   test_invalid˜   s(    	










c         C   sZ   |  i  t d d ƒ i t d d d ƒ i ƒ |  i t d d ƒ i t d d d ƒ i ƒ d  S(   Ns   a = 1
t   abcR   t   def(   R   R   t   co_filenameR   t   assertNotEquals(   R   (    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt   test_filename´   s    (	   t   __name__t
   __module__R   R    R%   R)   R,   R.   R3   (    (    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyR
      s   
	4	)	c           C   s   t  t ƒ d  S(   N(   R    R
   (    (    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt	   test_main»   s    t   __main__(   t   __doc__t   unittestt   test.test_supportR    R   t   codeopR   R   R   R   R	   t   TestCaseR
   R6   R4   (    (    (    s-   /mit/python/lib/python2.6/test/test_codeop.pyt   <module>   s   §	