Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_parser.cpython-39.pyc

a

��g8��@s&ddlZddlZe���&e�dde�ddlZWd�n1sD0YddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZGdd�dej�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedk�r"e��dS)�N�ignorezThe parser module is deprecated)�support)�assert_python_failure)�assert_python_okc@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dES)F�RoundtripLegalSyntaxTestCasec
Csn||�}|��}zt�|�}Wn8tjyV}z|�d||f�WYd}~n
d}~00|�||��d�dS)Nzcould not roundtrip %r: %sz!could not re-generate syntax tree)�totuple�parser�sequence2st�ParserError�fail�assertEqual)�self�f�s�st1�t�st2�why�r�,/usr/local/lib/python3.9/test/test_parser.py�	roundtrips(�z&RoundtripLegalSyntaxTestCase.roundtripcCs|�tj|�dS�N)rr�expr�r
rrrr�
check_expr"sz'RoundtripLegalSyntaxTestCase.check_exprcCs6t�d�}|��}i}t|i|�|�|dt�dS)Nz/from __future__ import unicode_literals; x = ''�x)r�suite�compile�execZassertIsInstance�str)r
r�codeZscoperrr�test_flags_passed%s

z.RoundtripLegalSyntaxTestCase.test_flags_passedcCs|�tj|�dSr)rrrrrrr�check_suite.sz(RoundtripLegalSyntaxTestCase.check_suitecCs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�|�d�|�d�dS)Nzdef f(): yield 1zdef f(): yieldzdef f(): x += yieldzdef f(): x = yield 1zdef f(): x = y = yield 1zdef f(): x = yieldzdef f(): x = y = yieldzdef f(): 1 + (yield)*2zdef f(): (yield 1)*2zdef f(): return; yield 1zdef f(): yield 1; returnzdef f(): yield from 1zdef f(): x = yield from 1zdef f(): f((yield from 1))zdef f(): yield 1; return 1z1def f():
    for x in range(30):
        yield x
z)def f():
    if (yield):
        yield x
�r"�r
rrr�test_yield_statement1s"















z1RoundtripLegalSyntaxTestCase.test_yield_statementcCs@|�d�|�d�|�d�|�d�|�d�|�d�dS)Nzasync def f():
 await smth()z"async def f():
 foo = await smth()z'async def f():
 foo, bar = await smth()zasync def f():
 (await smth())z#async def f():
 foo((await smth()))z&async def f():
 await foo(); return 42r#r$rrr�test_await_statementHs




z1RoundtripLegalSyntaxTestCase.test_await_statementcCs|�d�|�d�dS)Nz"async def f():
 async with 1: passz/async def f():
 async with a as b, c as d: passr#r$rrr�test_async_with_statementPs
z6RoundtripLegalSyntaxTestCase.test_async_with_statementcCs|�d�|�d�dS)Nz'async def f():
 async for i in (): passz*async def f():
 async for i, b in (): passr#r$rrr�test_async_for_statementTs
z5RoundtripLegalSyntaxTestCase.test_async_for_statementcCs|�d�|�d�dS)Nz3def f():
    x = 0
    def g():
        nonlocal x
z:def f():
    x = y = 0
    def g():
        nonlocal x, y
r#r$rrr�test_nonlocal_statementXs
z4RoundtripLegalSyntaxTestCase.test_nonlocal_statementcCs�|�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(�|�d)�dS)*Nzfoo(1)z	[1, 2, 3]z[x**3 for x in range(20)]z"[x**3 for x in range(20) if x % 3]z+[x**3 for x in range(20) if x % 2 if x % 3]�list(x**3 for x in range(20))z&list(x**3 for x in range(20) if x % 3)z/list(x**3 for x in range(20) if x % 2 if x % 3)z
foo(*args)zfoo(*args, **kw)z	foo(**kw)zfoo(key=value)zfoo(key=value, *args)zfoo(key=value, *args, **kw)zfoo(key=value, **kw)zfoo(a, b, c, *args)zfoo(a, b, c, *args, **kw)zfoo(a, b, c, **kw)zfoo(a, *args, keyword=23)z	foo + barz	foo - barz	foo * barz	foo / barz
foo // barz
(foo := 1)z	lambda: 0zlambda x: 0zlambda *y: 0zlambda *y, **z: 0z
lambda **z: 0zlambda x, y: 0zlambda foo=bar: 0z"lambda foo=bar, spaz=nifty+spit: 0zlambda foo=bar, **z: 0z#lambda foo=bar, blaz=blat+2, **z: 0z'lambda foo=bar, blaz=blat+2, *y, **z: 0zlambda x, *y, **z: 0z(x for x in range(10))zfoo(x for x in range(10))z...za[...]�rr$rrr�test_expressionsbsR







































z-RoundtripLegalSyntaxTestCase.test_expressionscCs|�d�dS)N�ar#r$rrr�test_simple_expression�sz3RoundtripLegalSyntaxTestCase.test_simple_expressioncCs|�d�|�d�dS)Nza = bza = b = c = d = er#r$rrr�test_simple_assignments�s
z4RoundtripLegalSyntaxTestCase.test_simple_assignmentscCs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�t��tdii�Wd�n1s�0Y|�t��tdii�Wd�n1s�0Y|�t��td
ii�Wd�n1s�0Y|�t��tdii�Wd�n1�s40Y|�t��tdii�Wd�n1�sl0Y|�t��tdii�Wd�n1�s�0Y|�t��tdii�Wd�n1�s�0Y|�t��tdii�Wd�n1�s0Y|�t��tdii�Wd�n1�sL0Y|�t��tdii�Wd�n1�s�0YdS)Nz
x: int = 5z"y: List[T] = []; z: [list] = fun()zx: tuple = (1, 2)zd[f()]: int = 42zf(d[x]): str = 'abc'zx.y.z.w: complex = 42jzx: intz#def f():
    x: str
    y: int = 5
z#class C:
    x: str
    y: int = 5
zIclass C:
    def __init__(self, x: int) -> None:
        self.x: int = x
z2+2: intz[]: int = 5zx, *y, z: int = range(5)zx: int = 1, y = 2z
u = v: intz
False: intzx.False: intz	x.y,: intz[0]: intzf(): int)r"�assertRaises�SyntaxErrorrr$rrr�test_var_annot�s<









***,,,,,,z+RoundtripLegalSyntaxTestCase.test_var_annotcCs||�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�dS)
Nza += bza -= bza *= bza /= bza //= bza %= bza &= bza |= bza ^= bza <<= bza >>= bza **= br#r$rrr�!test_simple_augmented_assignments�s










z>RoundtripLegalSyntaxTestCase.test_simple_augmented_assignmentscCs4|�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(�|�d)�|�d*�|�d+�|�d,�|�d-�|�d.�|�d/�|�d0�|�d1�|�d2�|�d3�|�d4�|�d5�|�d6�|�d7�|�d8�dS)9Nz
def f(): passzdef f(*args): passzdef f(*args, **kw): passzdef f(**kw): passzdef f(foo=bar): passzdef f(foo=bar, *args): passz!def f(foo=bar, *args, **kw): passzdef f(foo=bar, **kw): passzdef f(a, b): passzdef f(a, b, *args): passzdef f(a, b, *args, **kw): passzdef f(a, b, **kw): passzdef f(a, b, foo=bar): passz!def f(a, b, foo=bar, *args): passz'def f(a, b, foo=bar, *args, **kw): passz def f(a, b, foo=bar, **kw): passz@staticmethod
def f(): passz,@staticmethod
@funcattrs(x, y)
def f(): passz@funcattrs()
def f(): passz@False or x
def f(): passz@d := x
def f(): passz@lambda f: x(f)
def f(): passz@[..., x, ...][1]
def f(): passz@x(x)(x)
def f(): passz@(x, x)
def f(): passz@...
def f(): passz@None
def f(): passz@w @(x @y) @(z)
def f(): passz@w[x].y.z
def f(): passzdef f(*, a): passzdef f(*, a = 5): passzdef f(*, a = 5, b): passzdef f(*, a, b = 5): passz def f(*, a, b = 5, **kwds): passzdef f(*args, a): passzdef f(*args, a = 5): passzdef f(*args, a = 5, b): passzdef f(*args, a, b = 5): passz$def f(*args, a, b = 5, **kwds): passzdef f(a, /): passzdef f(a, /,): passzdef f(a, b, /): passzdef f(a, b, /, c): passzdef f(a, b, /, c = 6): passzdef f(a, b, /, c, *, d): passz!def f(a, b, /, c = 1, *, d): passz!def f(a, b, /, c, *, d = 1): passz%def f(a, b=1, /, c=2, *, d = 3): passz'def f(a=0, b=1, /, c=2, *, d = 3): passzdef f(a: int): passzdef f(a: int = 5): passzdef f(*args: list): passzdef f(**kwds: dict): passzdef f(*, a: int): passzdef f(*, a: int = 5): passzdef f() -> int: passr#r$rrr�test_function_defs�sp






















































z/RoundtripLegalSyntaxTestCase.test_function_defscCs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�dS)Nzclass foo():passzclass foo(object):passz!@class_decorator
class foo():passz&@class_decorator(arg)
class foo():passz(@decorator1
@decorator2
class foo():passz@False or x
class C: passz@d := x
class C: passz@lambda f: x(f)
class C: passz@[..., x, ...][1]
class C: passz@x(x)(x)
class C: passz@(x, x)
class C: passz@...
class C: passz@None
class C: passz@w @(x @y) @(z)
class C: passz@w[x].y.z
class C: passr#r$rrr�test_class_defss













z,RoundtripLegalSyntaxTestCase.test_class_defscCs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�|�d�|�d�dS)Nzfrom sys.path import *zfrom sys.path import dirnamezfrom sys.path import (dirname)zfrom sys.path import (dirname,)z*from sys.path import dirname as my_dirnamez,from sys.path import (dirname as my_dirname)z-from sys.path import (dirname as my_dirname,)z&from sys.path import dirname, basenamez(from sys.path import (dirname, basename)z)from sys.path import (dirname, basename,)z4from sys.path import dirname as my_dirname, basenamez6from sys.path import (dirname as my_dirname, basename)z7from sys.path import (dirname as my_dirname, basename,)z5from sys.path import dirname, basename as my_basenamez7from sys.path import (dirname, basename as my_basename)z8from sys.path import (dirname, basename as my_basename,)zfrom .bogus import xr#r$rrr�test_import_from_statement;s:









������z7RoundtripLegalSyntaxTestCase.test_import_from_statementcCs6|�d�|�d�|�d�|�d�|�d�dS)Nz
import syszimport sys as systemzimport sys, mathzimport sys as system, mathzimport sys, math as my_mathr#r$rrr�test_basic_import_statementTs




z8RoundtripLegalSyntaxTestCase.test_basic_import_statementcCsT|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�dS)	Nzfrom . import namezfrom .. import namezfrom ... import namezfrom .... import namezfrom .pkg import namezfrom ..pkg import namezfrom ...pkg import namezfrom ....pkg import namer#r$rrr�test_relative_imports[s






z2RoundtripLegalSyntaxTestCase.test_relative_importscCs|�d�dS)Nz"# -*- coding: iso-8859-1 -*-
pass
r#r$rrr�test_pep263gsz(RoundtripLegalSyntaxTestCase.test_pep263cCs|�d�dS)Nzassert alo < ahi and blo < bhi
r#r$rrr�test_assertksz(RoundtripLegalSyntaxTestCase.test_assertcCs"|�d�|�d�|�d�dS)Nzwith open('x'): pass
zwith open('x') as f: pass
z*with open('x') as f, open('y') as g: pass
r#r$rrr�	test_withns

z&RoundtripLegalSyntaxTestCase.test_withcCs@|�d�|�d�|�d�|�d�|�d�|�d�dS)Nztry: pass
except: pass
ztry: pass
finally: pass
z'try: pass
except A: pass
finally: pass
z4try: pass
except A: pass
except: pass
finally: pass
z"try: pass
except: pass
else: pass
z0try: pass
except: pass
else: pass
finally: pass
r#r$rrr�
test_try_stmtss




z*RoundtripLegalSyntaxTestCase.test_try_stmtcCs|�d�|�d�dS)Nzif True:
  pass
else:
  pass
z/if True:
  pass
elif True:
  pass
else:
  pass
r#r$rrr�test_if_stmt}s
z)RoundtripLegalSyntaxTestCase.test_if_stmtc	s$d}t�|�}�fdd��gd�}|�t�|jddd���|�|�t�|����dd�|D��|�t�|jdd	���d
d�|D��|�t�|jdd���dd�|D��|�t�|jddd���d
d�|D��|�t�tj|ddd���|�|�t�tj|ddd���dd�|D��dS)Nzdef f(x):
    return x + 1c3sP|d}|d}t|ttf�rF|dd�D]}�|�D]
}|Vq6q*n|VdS)Nr�)�
isinstance�tuple�list)�treeZ	node_type�next�eltr��walkrrrF�sz8RoundtripLegalSyntaxTestCase.test_position.<locals>.walk))r>�defr>r)r>rr>�)��(r>�)r>rr>�)��)r>rI)��:r>rM)rH�r>�	)rKrQ����)r>�returnrSrH)r>rrSrO)��+rS�
)rS�1rS�)rHrQrS�)rLrQrSrT)rHrQrSrT)rrQrSrTT)�	line_info�col_infocSsg|]\}}}}||f�qSrr��.0r�n�l�crrr�
<listcomp>��z>RoundtripLegalSyntaxTestCase.test_position.<locals>.<listcomp>)r\cSsg|]\}}}}|||f�qSrrr^rrrrc�rd)r]cSsg|]\}}}}|||f�qSrrr^rrrrc�rdcSsg|]}t|��qSr�rA�r_rrrrrc�rdcSsg|]}t|��qSrrerfrrrrc�rd)rrrrAr�tolistZst2tupleZst2list)r
r �stZexpectedrrEr�
test_position�s:

���������z*RoundtripLegalSyntaxTestCase.test_positioncCs,|�d�|�d�|�d�|�d�dS)Nz*a = yz
x, *b, = mz[*a, *b] = yzfor [*x, b] in x: passr#r$rrr�test_extended_unpacking�s


z4RoundtripLegalSyntaxTestCase.test_extended_unpackingcCs"|�d�|�d�|�d�dS)Nzraise
zraise e
zBtry:
    suite
except Exception as e:
    raise ValueError from e
r#r$rrr�test_raise_statement�s

z1RoundtripLegalSyntaxTestCase.test_raise_statementcCs|�d�|�d�dS)Nz[]z[*{2}, 3, *[4]]r+r$rrr�test_list_displays�s
z/RoundtripLegalSyntaxTestCase.test_list_displayscCs6|�d�|�d�|�d�|�d�|�d�dS)Nz{*{2}, 3, *[4]}z{2}z{2,}z{2, 3}z{2, 3,}r+r$rrr�test_set_displays�s




z.RoundtripLegalSyntaxTestCase.test_set_displayscCsJ|�d�|�d�|�d�|�d�|�d�|�d�|�d�dS)Nz{}z{a:b}z{a:b,}z
{a:b, c:d}z{a:b, c:d,}z{**{}}z{**{}, 3:4, **{5:6, 7:8}}r+r$rrr�test_dict_displays�s





z/RoundtripLegalSyntaxTestCase.test_dict_displayscCs6|�d�|�d�|�d�|�d�|�d�dS)Nz
f(*a, **b)zf(a, *b, *c, *d)zf(**a, **b)zf(2, *a, *b, **b, **c, **d)z0f(*b, *() or () and (), **{} and {}, **() or {})r+r$rrr�test_argument_unpacking�s




z4RoundtripLegalSyntaxTestCase.test_argument_unpackingcCs"|�d�|�d�|�d�dS)Nz{x for x in seq}z{f(x) for x in seq}z#{f(x) for x in seq if condition(x)}r+r$rrr�test_set_comprehensions�s

z4RoundtripLegalSyntaxTestCase.test_set_comprehensionscCs"|�d�|�d�|�d�dS)Nz{x:x for x in seq}z({x**2:x[3] for x in seq if condition(x)}z4{x:x for x in seq1 for y in seq2 if condition(x, y)}r+r$rrr�test_dict_comprehensions�s

z5RoundtripLegalSyntaxTestCase.test_dict_comprehensionscCs:|�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�dS)Nz(a := 1)z(a := a)z0if (match := pattern.search(data)) is None: passz-while match := pattern.search(f.read()): passz[y := f(x), y**2, y**3]z8filtered_data = [y for x in data if (y := f(x)) is None]z(y := f(x))zy0 = (y1 := f(x))zfoo(x=(y := f(x)))zdef foo(answer=(p := 42)): passz$def foo(answer: (p := 42) = 5): passzlambda: (x := 1)z(x := lambda: 1)z(x := lambda: (y := 1))z:lambda line: (m := re.match(pattern, line)) and m.group(1)zx = (y := 0)z(z:=(y:=(x:=0)))z(info := (name, phone, *rest))z(x:=1,2)z(total := total + tax)zlen(lines := f.readlines())zfoo(x := 3, cat='vector')zfoo(cat=(category := 'vector'))zAif any(len(longline := l) >= 100 for l in lines): print(longline)zFif env_base := os.environ.get('PYTHONUSERBASE', None): return env_basezNif self._is_special and (ans := self._check_nans(context=context)): return anszfoo(b := 2, a=1)zfoo((b := 2), a=1)zfoo(c=(b := 2), a=1)z{(x := C(i)).q: x for i in y}r#r$rrr�test_named_expressions�sF























��



z3RoundtripLegalSyntaxTestCase.test_named_expressionsN)%�__name__�
__module__�__qualname__rrr!r"r%r&r'r(r)r,r.r/r2r3r4r5r6r7r8r9r:r;r<r=rirjrkrlrmrnrorprqrrrrrrrsD	
+'Q 
4	rc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�IllegalSyntaxTestCasecCs6zt�|�Wntjy"Yn0|�d|�dS)Nz"did not detect invalid tree for %r)rr	r
r)r
rBZlabelrrr�check_bad_trees
z$IllegalSyntaxTestCase.check_bad_treecCs|�dd�dS)N)r>rS�z<junk>�rwr$rrr�	test_junkszIllegalSyntaxTestCase.test_junkcCsDd}|�|d�d}|�|d�d}|�|d�d}|�|d�dS)	N)�)�
)�)�)�)r>�rHrQr��rrQz too small items in terminal node)r{)r|)r})r~)r)r>spassr�r�r�z'non-string second item in terminal node)r{)r|)r})r~)r)r>�pass�0rr�r�r�z'non-integer third item in terminal node)r{)r|)r})r~)r)r>r�rrr�r�r�ztoo many items in terminal nodery�r
rBrrr�test_illegal_terminal!s�
�
�
�
z+IllegalSyntaxTestCase.test_illegal_terminalcCsd}|�|d�dS)N)r{��)�)i)r>rG)r>r)i)rIrJ)rMrN)rOrP)�#r�)rKrQ)r�)�	)�
)�)i)r>rU�i9)�$)�%)�&)�')�))�*)�+)�,)�-)�.)�/)�0)i1)rSrY)r�)r�)r�)r�)i)r>�yieldr�r�)rLrQr�r��def f():
  return 1
  yield 1ryr�rrr�test_illegal_yield_1Os�3z*IllegalSyntaxTestCase.test_illegal_yield_1cCsd}|�|d�dS)N)r{)r�)r�)r�)i�r>�from)i)r>Z
__future__�r>�import)i)r>�
generatorsr�r�r�ryr�rrr�test_illegal_yield_2�s�<z*IllegalSyntaxTestCase.test_illegal_yield_2cCsd}|�|d�dS)N)i)i7)�")r�)r�)r�)r�)�()r�)r�)r�)r�)r�)r�)r��r>r-���,r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r>rbr�r�za,,cryr�rrr�test_a_comma_comma_c�s�z*IllegalSyntaxTestCase.test_a_comma_comma_ccCsd}|�|d�dS)N)r{)r�)r�)r�)i)�8)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�r�)�)�%z$=)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r>�br�r�za $= bryr�rrr�test_illegal_operator�s�z+IllegalSyntaxTestCase.test_illegal_operatorcCsd}|�|d�dS)N)r{)r�)r�)r�)�)r>Zfoor�r�r�zmalformed global astryr�rrr�test_malformed_globalsz+IllegalSyntaxTestCase.test_malformed_globalcCsd}|�|d�dS)N)r{)r�)r|)r})r�)ir�r�)i)r�)r>Zfredr�r�r�zfrom import fredryr�rrr�test_missing_import_source
s�
z0IllegalSyntaxTestCase.test_missing_import_sourcecCs\d}|�|d�d}|�|d�d}|�t��t�|�Wd�n1sN0YdS)N)�U�r{r�zmissed encoding)r�r�s
iso-8859-1znon-string encoding)r�r�u�)rwr0�UnicodeEncodeErrorrr	r�rrr�test_illegal_encodings���z+IllegalSyntaxTestCase.test_illegal_encodingcCs4d}|�|d�d}|�|d�d}|�|d�dS)N)r{)r|)i����rQznegative node id)r{)r|)�crQzinvalid token id)r{)r|)i'r�zinvalid symbol idryr�rrr�test_invalid_node_id-sz*IllegalSyntaxTestCase.test_invalid_node_idc
CsZzt�d�WnFtjyT}z,|�dt|��|�dt|��WYd}~n
d}~00dS)N)r{)r|r�Z
compound_stmtZ
file_input)rr	r
�assertInr)r
rrrr�test_ParserError_message5s
z.IllegalSyntaxTestCase.test_ParserError_messageN)rsrtrurwrzr�r�r�r�r�r�r�r�r�r�rrrrrvs.7@!rvc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�CompileTestCasecCs(t�d�}t�|�}|�t|�d�dS)N�2 + 3rK�rr�	compilestr�eval)r
rhr rrr�test_compile_exprBs

z!CompileTestCase.test_compile_exprcCs6t�d�}t�|�}i}t||�|�|dd�dS)N�x = 2; y = x + 3�yrK)rrr�rr)r
rhr Zglobsrrr�test_compile_suiteGs



z"CompileTestCase.test_compile_suitecCst�d�}|�ttj|�dS)Nz	1 = 3 + 4�rrr0r1r��r
rhrrr�test_compile_errorNs
z"CompileTestCase.test_compile_errorcCs8t�d�}|�ttj|�t�d�}|�ttj|�dS)Nza = "\U12345678"z	a = "\u1"r�r�rrr�test_compile_badunicodeRs

z'CompileTestCase.test_compile_badunicodecCsBt�d�}t�|�}|�t|�d�t�|�}|�t|�d�dS)Nz-3���r�)r
rh�code1�code2rrr�test_issue_9011Xs



zCompileTestCase.test_issue_9011c	Cs>t�d�}t�|�}|�|jd�|��}|�|jd�dD]6}t�||�}|�|jd�|�|�}|�|jd�q<td�td�fD]�}|�t	��t�||�}Wd�n1s�0Y|�|jd�|�t	��|�|�}Wd�n1s�0Y|�|jd�q�|�
ttj|td��|�
t|jtd��dS)Nza + 5z
<syntax-tree>)�file.py�file.pyr�r�)
rrr�r�co_filenamer�	bytearray�
memoryviewZassertWarns�DeprecationWarningr0�	TypeErrorrA)r
rhr �filenamerrr�test_compile_filenamebs&


*(z%CompileTestCase.test_compile_filenameN)	rsrtrur�r�r�r�r�r�rrrrr�>s
r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�ParserStackLimitTestCasezitry to push the parser to/over its limits.
    see http://bugs.python.org/issue1881 for a discussion
    cCsd|d|S)N�[�]r)r
�levelrrr�_nested_expression|sz+ParserStackLimitTestCase._nested_expressioncCs |�d�}t�|�}|��dS)Nr�)r�rrr)r
�erhrrr�test_deeply_nested_lists

z0ParserStackLimitTestCase.test_deeply_nested_listcCs8|�d�}tdd|�\}}}|�d|�|�d|�dS)N�dz-Xoldparser�-css_push: parser stack overflowsMemoryError)r�rr�)r
r��rc�out�errrrr�test_trigger_memory_error�s
z2ParserStackLimitTestCase.test_trigger_memory_errorN)rsrtru�__doc__r�r�r�rrrrr�xsr�c@s4eZdZdZdd�Zdd�ZejZejdd��Z	dS)	�STObjectTestCasez(Test operations on ST objects themselvesc
Cst�d�}t�d�}t�d�}t�d�}t�d�}t�d�}|�||kd�|�||kd�|�||kd�|�||�|�||�|�||�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�t|||�}t|||�}t|||g�d}	|�||	k�|�||k�|�|	|k�|�||	k�|�||k�|�|	|k�|�||k�|�|	|	k�|�||k�|�|dkd�|�d|kd�|�t	t
j|d�|�t	t
jd|�|�t	t
j
|d	�|�t	t
jd
|�dS)Nr�r�r*TFr>g��hҘ@zspanish armadaiswaterloo)rrrr�min�max�sortedZ
assertTruer0r��operator�ge�le�lt�gt)
r
rrZst3Zst1_copyZst2_copyZst3_copyZbottom�topZmidrrr�test_comparisons�sf





z!STObjectTestCase.test_comparisonscCs�t�d�t�d�t�d�g}|D]z}t�|�}|�|��|���t�|�}|�|��|���ttj	d�D]*}t�
t�||��}|�|��|���qnq dS)Nr�r�r*r>)rrr�copyrr�deepcopy�range�pickle�HIGHEST_PROTOCOL�loads�dumps)r
�stsrhZst_copy�protorrr�test_copy_pickle�s�

z!STObjectTestCase.test_copy_picklecs�dd��t�d��t�d�����fdd������fdd�}|t�d	��|t�d
��|t�d��|t�d��|t�d
��|t�d��dS)NcSs0|dkr|S|dkr |dd@Sd|d��>S)Nr>�rx���)�
bit_length)r`rrr�
XXXROUNDUP�s
z0STObjectTestCase.test_sizeof.<locals>.XXXROUNDUPZPiiiZ	hP3iP0h2ics�|durdSd}t|�dko(t|dt�}|rB|t|d�d7}|rR|dd�n
|dd�}|r�|�t|���7}|D]}|�|�7}qz|S)Nrr>rT)�lenr?r)Znode�res�hasstrZchildren�child)r��nodesize�sizeofchildrenrrr�sz4STObjectTestCase.test_sizeof.<locals>.sizeofchildrencs ��|���|����dSr)�check_sizeofr)rh)�basesizer�r
rrr�check_st_sizeof�s
�z5STObjectTestCase.test_sizeof.<locals>.check_st_sizeofr�z	2 + 3 + 4z	x = 2 + 3rQz# -*- coding: utf-8 -*-a�[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,])rZcalcobjsize�struct�calcsizerrr)r
rr)r�rr�r
rr�test_sizeof�s

zSTObjectTestCase.test_sizeofN)
rsrtrur�r�r�rrZcpython_onlyrrrrrr��s=r�c@seZdZdd�ZdS)�OtherParserCasecCs:|�t��t�dd�Wd�n1s,0YdS)Nr-r�)r0r�rrr$rrr�test_two_args_to_exprsz%OtherParserCase.test_two_args_to_exprN)rsrtrurrrrrrsrc@seZdZdd�ZdS)�TestDeprecationcCs$d}td|�\}}}|�d|�dS)Nzdef f():
  import parser

f()r�s<string>:2: DeprecationWarning)rr�)r
r r�r�r�rrr�test_deprecation_messagesz(TestDeprecation.test_deprecation_messageN)rsrtrur
rrrrr	sr	�__main__)r��warnings�catch_warnings�filterwarningsr�rr�Zunittestr�r�testrZtest.support.script_helperrrZTestCaserrvr�r�r�rr	rs�mainrrrr�<module>s8
�&-:x


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists