ó
v®¸Qc           @€  sv  d  Z  d d l m Z d d l m Z 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 d d
 l m Z d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e j f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d S(    sF  Test suite for 2to3's parser and grammar files.

This is the place to add tests for changes to 2to3's grammar, such as those
merging the grammars for Python 2 and 3. In addition to specific tests for
parts of the grammar we've changed, we also make sure we can parse the
test_grammar.py files from both Python 2 and Python 3.
iÿÿÿÿ(   t   with_statementi   (   t   support(   t   drivert   test_dirN(   t   tokenizei   (   t
   ParseError(   t   python_symbolst
   TestDriverc           B€  s   e  Z d  „  Z RS(   c         C€  sa   d } t  j | ƒ } |  j | j d j d j t j ƒ |  j | j d j d j t j ƒ d  S(   Ns   print 1
print 2
i    i   (   R   t   parse_stringt   assertEqualt   childrent   typet   symst
   print_stmt(   t   selft   st   t(    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_formfeed   s    $(   t   __name__t
   __module__R   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR      s   t   GrammarTestc           B€  s   e  Z d  „  Z d „  Z RS(   c         C€  s   t  j | ƒ d  S(   N(   R   R   (   R   t   code(    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   validate#   s    c         C€  s5   y |  j  | ƒ Wn t k
 r$ n Xt d ƒ ‚ d  S(   Ns    Syntax shouldn't have been valid(   R   R   t   AssertionError(   R   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   invalid_syntax&   s
    (   R   R   R   R   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR   "   s   	t   TestRaiseChangesc           B€  sY   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   c         C€  s   |  j  d ƒ d  S(   Nt   raise(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_2x_style_10   s    c         C€  s   |  j  d ƒ d  S(   Ns
   raise E, V(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_2x_style_23   s    c         C€  s   |  j  d ƒ d  S(   Ns   raise E, V, T(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_2x_style_36   s    c         C€  s   |  j  d ƒ d  S(   Ns   raise E, V, T, Z(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_2x_style_invalid_19   s    c         C€  s   |  j  d ƒ d  S(   Ns   raise E1 from E2(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_3x_style<   s    c         C€  s   |  j  d ƒ d  S(   Ns   raise E, V from E1(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_3x_style_invalid_1?   s    c         C€  s   |  j  d ƒ d  S(   Ns   raise E from E1, E2(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_3x_style_invalid_2B   s    c         C€  s   |  j  d ƒ d  S(   Ns   raise from E1, E2(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_3x_style_invalid_3E   s    c         C€  s   |  j  d ƒ d  S(   Ns   raise E from(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_3x_style_invalid_4H   s    (   R   R   R   R   R   R   R   R    R!   R"   R#   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR   /   s   								t   TestFunctionAnnotationsc           B€  sP   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         C€  s   |  j  d ƒ d  S(   Ns   def f(x) -> list: pass(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_1N   s    c         C€  s   |  j  d ƒ d  S(   Ns   def f(x:int): pass(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_2Q   s    c         C€  s   |  j  d ƒ d  S(   Ns   def f(*x:str): pass(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_3T   s    c         C€  s   |  j  d ƒ d  S(   Ns   def f(**x:float): pass(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_4W   s    c         C€  s   |  j  d ƒ d  S(   Ns   def f(x, y:1+2): pass(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_5Z   s    c         C€  s   |  j  d ƒ d  S(   Ns   def f(a, (b:1, c:2, d)): pass(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_6]   s    c         C€  s   |  j  d ƒ d  S(   Ns/   def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6): pass(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_7`   s    c         C€  s   d } |  j  | ƒ d  S(   Nsg   def f(a, (b:1, c:2, d), e:3=4, f=5,
                        *g:6, h:7, i=8, j:9=10, **k:11) -> 12: pass(   R   (   R   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_8c   s    (
   R   R   R%   R&   R'   R(   R)   R*   R+   R,   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR$   M   s   							t
   TestExceptc           B€  s   e  Z d  „  Z d „  Z RS(   c         C€  s   d } |  j  | ƒ d  S(   NsP   
            try:
                x
            except E as N:
                y(   R   (   R   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_newj   s    c         C€  s   d } |  j  | ƒ d  S(   NsN   
            try:
                x
            except E, N:
                y(   R   (   R   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_oldr   s    (   R   R   R.   R/   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR-   i   s   	t   TestSetLiteralc           B€  s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C€  s   |  j  d ƒ d  S(   Ns   x = {'one'}(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR%   }   s    c         C€  s   |  j  d ƒ d  S(   Ns   x = {'one', 1,}(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR&   €   s    c         C€  s   |  j  d ƒ d  S(   Ns   x = {'one', 'two', 'three'}(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR'   ƒ   s    c         C€  s   |  j  d ƒ d  S(   Ns   x = {2, 3, 4,}(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR(   †   s    (   R   R   R%   R&   R'   R(   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR0   |   s   			t   TestNumericLiteralsc           B€  s   e  Z d  „  Z d „  Z RS(   c         C€  s   |  j  d ƒ |  j d ƒ d  S(   Nt   0o7777777777777t   0o7324528887(   R   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_new_octal_notation‹   s    c         C€  s   |  j  d ƒ |  j d ƒ d  S(   Nt   0b101010t	   0b0101021(   R   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_new_binary_notation   s    (   R   R   R4   R7   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR1   Š   s   	t   TestClassDefc           B€  s   e  Z d  „  Z RS(   c         C€  sE   |  j  d ƒ |  j  d ƒ |  j  d ƒ |  j  d ƒ |  j  d ƒ d  S(   Ns   class B(t=7): passs   class B(t, *args): passs   class B(t, **kwargs): passs!   class B(t, *args, **kwargs): passs&   class B(t, y=9, *args, **kwargs): pass(   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_new_syntax•   s
    (   R   R   R9   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR8   ”   s   t   TestParserIdempotencyc           B€  s    e  Z d  Z d „  Z d „  Z RS(   s,   A cut-down version of pytree_idempotency.py.c         C€  sí   t  j j d ƒ r d  SxÐ t j ƒ  D]Â } t | d ƒ  } t j | j ƒ d } Wd  QX|  j	 | d  k	 d | ƒ t | d ƒ " } | j ƒ  } | j | ƒ } Wd  QXt j | ƒ } t | ƒ } t | | | ƒ r# |  j d | ƒ q# q# Wd  S(   Nt   wint   rbi    s   can't detect encoding for %st   rs   Idempotency failed: %s(   t   syst   platformt
   startswithR   t   all_project_filest   openR   t   detect_encodingt   readlinet
   assertTruet   Nonet   readt   decodeR   R   t   unicodet   difft   fail(   R   t   filepatht   fpt   encodingt   sourcet   treet   new(    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_all_project_files¡   s    c         C€  s8   t  j d ƒ t  j d ƒ t  j d ƒ t  j d ƒ d  S(   Ns   a, *b, c = x
s   [*a, b] = x
s   (z, *y, w) = m
s   for *z, m in d: pass
(   R   R   (   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_extended_unpacking²   s    (   R   R   t   __doc__RR   RS   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR:      s   	t   TestLiteralsc           B€  s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C€  s   t  j t j | ƒ d ƒ d  S(   Ns   

(   R   R   R   t   dedent(   R   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyR   º   s    c         C€  s   d } |  j  | ƒ d  S(   Nsá   
            md5test(b"ª" * 80,
                    (b"Test Using Larger Than Block-Size Key "
                     b"and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            (   R   (   R   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_multiline_bytes_literals½   s    c         C€  s   d } |  j  | ƒ d  S(   Ns¬   
            b"""
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN">
            """
            (   R   (   R   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt'   test_multiline_bytes_tripquote_literalsÆ   s    c         C€  s   d } |  j  | ƒ d  S(   NsÞ   
            md5test("ª" * 80,
                    ("Test Using Larger Than Block-Size Key "
                     "and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            (   R   (   R   R   (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   test_multiline_str_literalsÏ   s    (   R   R   R   RW   RX   RY   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyRU   ¸   s   					c         C€  ss   t  d d ƒ } z | j | j | ƒ ƒ Wd  | j ƒ  Xz' |  j d d ƒ }  t j d |  ƒ SWd  t j d ƒ Xd  S(   Nt   @t   wt   "s   \"s   diff -u "%s" @(   RB   t   writet   encodet   closet   replacet   ost   systemt   remove(   t   fnt   resultRN   t   f(    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyRJ   Ù   s    (   RT   t
   __future__R    t    R   R   R   Ra   R>   t   lib2to3.pgen2R   t   pgen2.parseR   t   lib2to3.pygramR   R   t   TestCaseR   R   R   R$   R-   R0   R1   R8   R:   RU   RJ   (    (    (    s/   /sys/lib/python2.7/lib2to3/tests/test_parser.pyt   <module>   s&   	
	!