HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_parser.cpython-37.pyc
B

��g���@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	Gdd�dej
�ZGdd�dej
�ZGdd	�d	ej
�Z
Gd
d�dej
�ZGdd
�d
ej
�ZGdd�dej
�Zedkr�e��dS)�N)�support)�assert_python_failurec@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#dCS)D�RoundtripLegalSyntaxTestCasec
Csl||�}|��}yt�|�}Wn6tjk
rT}z|�d||f�Wdd}~XYnX|�||��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.7/test/test_parser.py�	roundtrips$z&RoundtripLegalSyntaxTestCase.roundtripcCs|�tj|�dS)N)rr�expr)rr
rrr�
check_exprsz'RoundtripLegalSyntaxTestCase.check_exprcCs6t�d�}|��}i}t|i|�|�|dt�dS)Nz/from __future__ import unicode_literals; x = ''�x)r�suite�compile�execZassertIsInstance�str)rr�codeZscoperrr�test_flags_passed s

z.RoundtripLegalSyntaxTestCase.test_flags_passedcCs|�tj|�dS)N)rrr)rr
rrr�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)rrrr�test_yield_statement,s"















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 42)r)rrrr�test_await_statementCs




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: pass)r)rrrr�test_async_with_statementKs
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 (): pass)r)rrrr�test_async_for_statementOs
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)rrrr�test_nonlocal_statementSs
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(�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]zlist(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	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[...])r)rrrr�test_expressions]sP






































z-RoundtripLegalSyntaxTestCase.test_expressionscCs|�d�dS)N�a)r)rrrr�test_simple_expression�sz3RoundtripLegalSyntaxTestCase.test_simple_expressioncCs|�d�|�d�dS)Nza = bza = b = c = d = e)r)rrrr�test_simple_assignments�s
z4RoundtripLegalSyntaxTestCase.test_simple_assignmentsc	Cs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�t��tdii�WdQRX|�t��tdii�WdQRX|�t��td
ii�WdQRX|�t��tdii�WdQRX|�t��tdii�WdQRX|�t��tdii�WdQRX|�t��tdii�WdQRX|�t��tdii�WdQRX|�t��tdii�WdQRX|�t��tdii�WdQRXdS)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)zt: tuple = 1, 2z
u = v: intz
False: intzx.False: intz	x.y,: intz[0]: intzf(): int)r�assertRaises�SyntaxErrorr)rrrr�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 **= b)r)rrrr�!test_simple_augmented_assignments�s










z>RoundtripLegalSyntaxTestCase.test_simple_augmented_assignmentscCsl|�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)%Nz
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(): 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: 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: pass)r)rrrr�test_function_defs�sH


































z/RoundtripLegalSyntaxTestCase.test_function_defscCs6|�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():pass)r)rrrr�test_class_defs�s




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 x)r)rrrr�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_math)r)rrrr�test_basic_import_statements




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 name)r)rrrr�test_relative_importss






z2RoundtripLegalSyntaxTestCase.test_relative_importscCs|�d�dS)Nz"# -*- coding: iso-8859-1 -*-
pass
)r)rrrr�test_pep263+sz(RoundtripLegalSyntaxTestCase.test_pep263cCs|�d�dS)Nzassert alo < ahi and blo < bhi
)r)rrrr�test_assert/sz(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)rrrr�	test_with2s

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)rrrr�
test_try_stmt7s




z*RoundtripLegalSyntaxTestCase.test_try_stmtcCs|�d�|�d�dS)Nzif True:
  pass
else:
  pass
z/if True:
  pass
elif True:
  pass
else:
  pass
)r)rrrr�test_if_stmtAs
z)RoundtripLegalSyntaxTestCase.test_if_stmtcs@d}t�|�}�fdd��dddddd	d
ddd
ddddddg}|�t�|jddd���|�|�t�|����dd�|D��|�t�|jdd���dd�|D��|�t�|jdd���dd�|D��|�t�|jddd���dd�|D��|�t�tj|ddd���|�|�t�tj|ddd���dd�|D��dS)Nzdef f(x):
    return x + 1c3sX|d}|d}t|ttf�rNx4|dd�D]}x�|�D]
}|Vq:Wq,Wn|VdS)Nr�)�
isinstance�tuple�list)�treeZ	node_type�nextZeltr)�walkrrr<Ksz8RoundtripLegalSyntaxTestCase.test_position.<locals>.walk)r6�defr6r)r6rr6�)��(r6�)r6rr6�)��)r6r?)��:r6rC)r>�r6�	)rArG����)r6�returnrIr>)r6rrIrE)��+rI�
)rI�1rI�)r>rGrI�)rBrGrIrJ)r>rGrIrJ)rrGrIrJT)�	line_info�col_infocSsg|]\}}}}||f�qSrr)�.0r�n�l�crrr�
<listcomp>ksz>RoundtripLegalSyntaxTestCase.test_position.<locals>.<listcomp>)rRcSsg|]\}}}}|||f�qSrr)rTrrUrVrWrrrrXms)rScSsg|]\}}}}|||f�qSrr)rTrrUrVrWrrrrXoscSsg|]}t|��qSr)r9)rTrrrrrXqscSsg|]}t|��qSr)r9)rTrrrrrXws)rrr
r9r�tolistZst2tupleZst2list)rr�stZexpectedr)r<r�
test_positionEsF


z*RoundtripLegalSyntaxTestCase.test_positioncCs,|�d�|�d�|�d�|�d�dS)Nz*a = yz
x, *b, = mz[*a, *b] = yzfor [*x, b] in x: pass)r)rrrr�test_extended_unpackingys


z4RoundtripLegalSyntaxTestCase.test_extended_unpackingcCs"|�d�|�d�|�d�dS)Nzraise
zraise e
zBtry:
    suite
except Exception as e:
    raise ValueError from e
)r)rrrr�test_raise_statements

z1RoundtripLegalSyntaxTestCase.test_raise_statementcCs|�d�|�d�dS)Nz[]z[*{2}, 3, *[4]])r)rrrr�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)rrrr�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)rrrr�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)rrrr�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)rrrr�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)rrrr�test_dict_comprehensions�s

z5RoundtripLegalSyntaxTestCase.test_dict_comprehensionsN)$�__name__�
__module__�__qualname__rrrrrr r!r"r#r$r&r'r*r+r,r-r.r/r0r1r2r3r4r5r[r\r]r^r_r`rarbrcrrrrrsB	
*'0
4	rc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�IllegalSyntaxTestCasecCs8yt�|�Wntjk
r$YnX|�d|�dS)Nz"did not detect invalid tree for %r)rrrr	)rr:Zlabelrrr�check_bad_tree�s
z$IllegalSyntaxTestCase.check_bad_treecCs|�dd�dS)N)r6rI�z<junk>)rh)rrrr�	test_junk�szIllegalSyntaxTestCase.test_junkcCsDd}|�|d�d}|�|d�d}|�|d�d}|�|d�dS)	N)i)i
)i)i)i)r6)r>rG)r>rG)rrGz too small items in terminal node)i)i
)i)i)i)r6spass)r>rG)r>rG)rrGz'non-string second item in terminal node)i)i
)i)i)i)r6�pass�0r)r>rG)r>rG)rrGz'non-integer third item in terminal node)i)i
)i)i)i)r6rkrr)r>rG)r>rG)rrGztoo many items in terminal node)rh)rr:rrr�test_illegal_terminal�s				z+IllegalSyntaxTestCase.test_illegal_terminalcCsd}|�|d�dS)N)i)i)i)i)r6r=)r6r)i)r?r@)rCrD)rErF)i#)r>rG)rArG)i)i	)i
)i)i)r6rK)i9)i$)i%)i&)i')i))i*)i+)i,)i-)i.)i/)i0)i1)rIrO)i)i	)i
)i)i)r6�yield)i9)i$)i%)i&)i')i))i*)i+)i,)i-)i.)i/)i0)i1)rIrO)r>rG)rBrG)r>rG)rrGzdef f():
  return 1
  yield 1)rh)rr:rrr�test_illegal_yield_1�s2z*IllegalSyntaxTestCase.test_illegal_yield_1cCsd}|�|d�dS)N)i)i)i	)i
)i)r6�from)i)r6Z
__future__)r6�import)i)r6Z
generators)r>rG)i)i)i)r6r=)r6r)i)r?r@)rCrD)rErF)i#)r>rG)rArG)i)i	)i
)i)i)r6rK)i9)i$)i%)i&)i')i))i*)i+)i,)i-)i.)i/)i0)i1)rIrO)i)i	)i
)i)i)r6rn)i9)i$)i%)i&)i')i))i*)i+)i,)i-)i.)i/)i0)i1)rIrO)r>rG)rBrG)r>rG)rrGzdef f():
  return 1
  yield 1)rh)rr:rrr�test_illegal_yield_2%s;z*IllegalSyntaxTestCase.test_illegal_yield_2cCsd}|�|d�dS)N)i)i7)i")i#)i$)i%)i')i()i))i*)i+)i,)i-)i.)i/)r6r%)��,)rsrt)i")i#)i$)i%)i')i()i))i*)i+)i,)i-)i.)i/)r6rW)r>rG)rrGza,,c)rh)rr:rrr�test_a_comma_comma_cesz*IllegalSyntaxTestCase.test_a_comma_comma_ccCsd}|�|d�dS)N)i)i)i	)i
)i)i8)i#)i$)i%)i&)i()i))i*)i+)i,)i-)i.)i/)i0)r6r%)i)�%z$=)i8)i#)i$)i%)i&)i()i))i*)i+)i,)i-)i.)i/)i0)r6�b)r>rG)rrGza $= b)rh)rr:rrr�test_illegal_operator�sz+IllegalSyntaxTestCase.test_illegal_operatorcCsd}|�|d�dS)N)i)i)i	)i
)i)r6Zfoo)r>rG)r>rG)rrGzmalformed global ast)rh)rr:rrr�test_malformed_global�sz+IllegalSyntaxTestCase.test_malformed_globalcCsd}|�|d�dS)N)i)i)i
)i)i)i)r6rp)r6rq)i)i)r6Zfred)r>rG)r>rG)rrGzfrom import fred)rh)rr:rrr�test_missing_import_source�s	z0IllegalSyntaxTestCase.test_missing_import_sourcec	CsHd}|�|d�d}|�|d�d}|�t��t�|�WdQRXdS)N)iT)i)rrGzmissed encoding)iT)i)rrGs
iso-8859-1znon-string encoding)iT)i)rrGu�)rhr(�UnicodeEncodeErrorrr)rr:rrr�test_illegal_encoding�sz+IllegalSyntaxTestCase.test_illegal_encodingcCs4d}|�|d�d}|�|d�d}|�|d�dS)N)i)i
)i����rGznegative node id)i)i
)�crGzinvalid token id)i)i
)i')rrGzinvalid symbol id)rh)rr:rrr�test_invalid_node_id�sz*IllegalSyntaxTestCase.test_invalid_node_idc
CsXyt�d�WnDtjk
rR}z$|�dt|��|�dt|��Wdd}~XYnXdS)N)i)i
)i)rrGZsimple_stmtZ
file_input)rrr�assertInr)rrrrr�test_ParserError_message�s
z.IllegalSyntaxTestCase.test_ParserError_messageN)rdrerfrhrjrmrorrrurxryrzr|r~r�rrrrrg�s.7@!rgc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�CompileTestCasecCs(t�d�}t�|�}|�t|�d�dS)Nz2 + 3rA)rr�	compilestr
�eval)rrZrrrr�test_compile_expr�s

z!CompileTestCase.test_compile_exprcCs6t�d�}t�|�}i}t||�|�|dd�dS)Nzx = 2; y = x + 3�yrA)rrr�rr
)rrZrZglobsrrr�test_compile_suite�s



z"CompileTestCase.test_compile_suitecCst�d�}|�ttj|�dS)Nz	1 = 3 + 4)rrr(r)r�)rrZrrr�test_compile_error�s
z"CompileTestCase.test_compile_errorcCs8t�d�}|�ttj|�t�d�}|�ttj|�dS)Nza = "\U12345678"z	a = "\u1")rrr(r)r�)rrZrrr�test_compile_badunicode�s

z'CompileTestCase.test_compile_badunicodecCsBt�d�}t�|�}|�t|�d�t�|�}|�t|�d�dS)Nz-3���)rrr�r
r�)rrZ�code1�code2rrr�test_issue_9011�s



zCompileTestCase.test_issue_9011c
Cst�d�}t�|�}|�|jd�|��}|�|jd�x>dD]6}t�||�}|�|jd�|�|�}|�|jd�q>Wxvtd�td�fD]b}|�t	��t�||�}WdQRX|�|jd�|�t	��|�|�}WdQRX|�|jd�q�W|�
ttj|td��|�
t|jtd��dS)Nza + 5z
<syntax-tree>)zfile.pysfile.pyzfile.pysfile.py)
rrr�r
�co_filenamer�	bytearray�
memoryviewZassertWarns�DeprecationWarningr(�	TypeErrorr9)rrZr�filenamerrr�test_compile_filenames&



z%CompileTestCase.test_compile_filenameN)	rdrerfr�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_expressionsz+ParserStackLimitTestCase._nested_expressioncCs |�d�}t�|�}|��dS)N�])r�rrr)r�erZrrr�test_deeply_nested_lists

z0ParserStackLimitTestCase.test_deeply_nested_listcCs6|�d�}td|�\}}}|�d|�|�d|�dS)N�dz-css_push: parser stack overflowsMemoryError)r�rr)rr�Zrc�out�errrrr�test_trigger_memory_error$s
z2ParserStackLimitTestCase.test_trigger_memory_errorN)rdrerf�__doc__r�r�r�rrrrr�sr�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)Nz2 + 3zx = 2; y = x + 3zlist(x**3 for x in range(20))TFr6g��hҘ@zspanish armadaiswaterloo)rrrr
�min�max�sortedZ
assertTruer(r��operator�ge�le�lt�gt)
rrrZst3Zst1_copyZst2_copyZst3_copyZbottom�topZmidrrr�test_comparisons/sf





z!STObjectTestCase.test_comparisonscCs�t�d�t�d�t�d�g}x�|D]~}t�|�}|�|��|���t�|�}|�|��|���x<ttj	d�D]*}t�
t�||��}|�|��|���qrWq"WdS)Nz2 + 3zx = 2; y = x + 3zlist(x**3 for x in range(20))r6)rrr�copyr
rZdeepcopy�range�pickleZHIGHEST_PROTOCOL�loads�dumps)r�stsrZZst_copy�protorrr�test_copy_picklels


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)Nr6�ri���)�
bit_length)rUrrr�
XXXROUNDUPs
z0STObjectTestCase.test_sizeof.<locals>.XXXROUNDUPZPiiZhP3iP0hcs�|dkrdSd}t|�dko(t|dt�}|rB|t|d�d7}|rR|dd�n
|dd�}|r�|�t|���7}x|D]}|�|�7}q|W|S)Nrr6rJ)�lenr7r)ZnodeZres�hasstrZchildrenZchild)r��nodesize�sizeofchildrenrrr��s
z4STObjectTestCase.test_sizeof.<locals>.sizeofchildrencs ��|���|����dS)N)�check_sizeofr)rZ)�basesizer�rr�rr�check_st_sizeof�sz5STObjectTestCase.test_sizeof.<locals>.check_st_sizeofz2 + 3z	2 + 3 + 4z	x = 2 + 3rGz# -*- 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)rr�r)r�r�r�rr�r�test_sizeof}s

zSTObjectTestCase.test_sizeofN)
rdrerfr�r�r�rr�Zcpython_onlyr�rrrrr�,s
=r�c@seZdZdd�ZdS)�OtherParserCasec	Cs&|�t��t�dd�WdQRXdS)Nr%rw)r(r�rr)rrrr�test_two_args_to_expr�sz%OtherParserCase.test_two_args_to_exprN)rdrerfr�rrrrr��sr��__main__)r�rr�Zunittestr�r�ZtestrZtest.support.script_helperrZTestCaserrgr�r�r�r�rd�mainrrrr�<module>s(%-:x