Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/lib2to3/tests/data/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/lib2to3/tests/data/__pycache__/py3_test_grammar.cpython-35.pyc



��Yf�v�@s�ddlmZmZddlZddlZddlTGdd�dej�ZGdd�dej�Zdd	�Ze	d
kr�e�dS)�)�run_unittest�check_syntax_errorN)�*c@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�
TokenTestscCs6d}|j|dd�d}|j|dd�dS)N��zbackslash for line continuationrzbackslash ending commentr)�assertEquals)�self�x�r�H/opt/alt/python35/lib64/python3.5/lib2to3/tests/data/py3_test_grammar.py�
testBackslashs
zTokenTests.testBackslashcCs�|jtd�td��|jdd�|jdd�|jdd�|jdd�|jttd�ddlm}|dkr|jdd�|jd	dk�|jd	dk�|jddk�x�dD]<}yt|�}Wq�tk
r|j	d|�Yq�Xq�Wn�|dkr�|jdd�|jddk�|jddk�|jddk�xXdD]<}yt|�}Wqztk
r�|j	d|�YqzXqzWn|j	d|�dS) Nr�i����	Z0x)�maxsizerll���
2147483648�
0o40000000000�0x100000000�"0b10000000000000000000000000000000z(OverflowError on huge integer literal %rl����ll����l�����9223372036854775808�0o2000000000000000000000�0x10000000000000000�A0b100000000000000000000000000000000000000000000000000000000000000zWeird maxsize value %ri�i�i�)rrrrl��������l����l����)rrrr)
r�type�assertRaises�SyntaxError�eval�sysr�assert_�
OverflowError�fail)r	r�sr
rrr�testPlainIntegerss>



zTokenTests.testPlainIntegerscCs4d}d}d}d}d}d}d}d}dS)Nrl����l���?l�
~��l!]cll�����r)r	r
rrr�testLongIntegersAszTokenTests.testLongIntegerscCsFd}d}d}d}d}d}d}d}d}d}d}dS)Ng��Q�	@g�s@gj�t��?g��
�Bg��t� =g�W�H�BgF�@r)r	r
rrr�
testFloatsKszTokenTests.testFloatscCs{d}d}|jt|�dko-||k�d}d}|jt|�dkop||kopt|�dk�d}d}|jt|�dko�||ko�t|�dk�d}d}|jt|�d	ko�||k�d
}d
}|jt|�d	ko||k�d}d}|j||�d}|j||�d}|j||�d}|j||�dS)N�r�'r�'�"�"zdoesn't "shrink" does it�zdoes "shrink" doesn't itz2
The "quick"
brown fox
jumps over
the 'lazy' dog.
)r�len�ordr)r	r
�yrrr�testStringLiteralsYs0%77%%zTokenTests.testStringLiteralscCs0d}|j|tk�|jttd�dS)N.z.. .)r�Ellipsisrrr)r	r
rrr�testEllipsis�szTokenTests.testEllipsisN)	�__name__�
__module__�__qualname__r
r"r#r$r.r0rrrrrs
$
(rc@s�eZdZdd�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$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMS)N�GrammarTestscCstd�}dS)Nz	1, 0 or 1)r)r	r
rrr�
testEvalInput�szGrammarTests.testEvalInputcs�
dd�}|�|f�|fi�dd�}dd�}|j|jjdf�|j|jjdd	f�d
d�}dd
�}dd�}dd�}dd�}|�|d�|d�|dd�|dd�|�|d�|d�|dd�|dddddddddd�
|d�|d�|dd�|ddd�|dddddddddd�
|dd�|ddd�|dddd�|dddddddddd�
ddd�}	|	�|	d�|	df�|	d di�dd!d"�}
|
d�|
dd�|
dd#di�dd$d%�}|dd�|ddd�|dddf�|dddf�|dddf�|ddd&di�ddd'd(�}|�|d�|dd�|ddf�|ddf�|dd#di�|d dd#di�ddd)d*�}
|
d�|
dd�|
ddd�ddd+d,�}|dd�|ddd�|dddd�dd-d.�}|�|d�|dd�|ddddf�|df�|d di�dd/d0�}|d�|dd�|ddd�dd1d2�}|dd�|ddd�|dddd�|ddddf�|ddd&di�ddd3d4�}|�|d�|dd�|ddd�|ddddf�|d dd#di�ddd5d6�}|d�|dd�|ddd�|dddd�|ddddf�|dddddf�|ddfd&di�ddd7d8�}|dd�|ddd�|dddd�|ddddd�|ddddf�|dddddf�|dddfd9di�ytd:d;di�Wntk
r�YnX|jd<�d=d>�}|d?d@�dAd@dBdC�}|dddDd@�|dddDd@dAdE�|dddAd@dDdE�dDd@dFdG�}|dddAd@dHd@dIdE�|dddHd@dIdEdAd@�dJdK�}|j|dddgd:ddLd�dddfd:ddLdif�|jttdM�|jttdN�t	dOdPdK��}|j|j
dQt	i�tdRdSdK��}|j|j
d:ti�tdRdTdK��}|j|j
d:ti�tdRdUdK��}|j|j
d:ti�dddVdWdK��}|j|j
dLdi�dddXdYdK��}|j|j
d#dd&di�dddddddZd[dK��}|j|j
d#dd&dd\dd]di�ddd^dd_d`dddddddadbdcdddK�	�}|j|j
d#dd&dd\dd]ddedd_ddfdadQdbi�dgdh�}|t	dOdidK���}|j|j
dQt	i�d��fdjdK�}d�fdkdK�}dfd�fdldK�}tdO�fdmdK��}t
|dn�t
|do�dS)�NcSsdS)Nrrrrr�f1�sz$GrammarTests.testFuncdef.<locals>.f1cSsdS)Nr)�one_argumentrrr�f2�sz$GrammarTests.testFuncdef.<locals>.f2cSsdS)Nr)�two�	argumentsrrr�f3�sz$GrammarTests.testFuncdef.<locals>.f3r7r9r:cSsdS)Nr)Zone_argrrr�a1�sz$GrammarTests.testFuncdef.<locals>.a1cSsdS)Nr)r9�argsrrr�a2�sz$GrammarTests.testFuncdef.<locals>.a2cWsdS)Nr)�restrrr�v0�sz$GrammarTests.testFuncdef.<locals>.v0cWsdS)Nr)�ar?rrr�v1�sz$GrammarTests.testFuncdef.<locals>.v1cWsdS)Nr)rA�br?rrr�v2�sz$GrammarTests.testFuncdef.<locals>.v2rr������rrcSsdS)Nr)rArrr�d01�sz%GrammarTests.testFuncdef.<locals>.d01rAcSsdS)Nr)rArCrrr�d11�sz%GrammarTests.testFuncdef.<locals>.d11rCcSsdS)Nr)rArC�crrr�d21�sz%GrammarTests.testFuncdef.<locals>.d21rMcSsdS)Nr)rArCrrr�d02�sz%GrammarTests.testFuncdef.<locals>.d02cSsdS)Nr)rArCrMrrr�d12�sz%GrammarTests.testFuncdef.<locals>.d12cSsdS)Nr)rArCrM�drrr�d22�sz%GrammarTests.testFuncdef.<locals>.d22cWsdS)Nr)rAr?rrr�d01v�sz&GrammarTests.testFuncdef.<locals>.d01vcWsdS)Nr)rArCr?rrr�d11v�sz&GrammarTests.testFuncdef.<locals>.d11vcWsdS)Nr)rArCrMr?rrr�d21v�sz&GrammarTests.testFuncdef.<locals>.d21vcWsdS)Nr)rArCr?rrr�d02v�sz&GrammarTests.testFuncdef.<locals>.d02vcWsdS)Nr)rArCrMr?rrr�d12v�sz&GrammarTests.testFuncdef.<locals>.d12vcWsdS)Nr)rArCrMrQr?rrr�d22vsz&GrammarTests.testFuncdef.<locals>.d22vrQr
sfooz/Bytes should not work as keyword argument namescSs|S)Nr)�keyrrr�pos0key1sz*GrammarTests.testFuncdef.<locals>.pos0key1rY�d�k2cSs||||fS)Nr)�p1�p2�k1r\rrr�pos2key2sz*GrammarTests.testFuncdef.<locals>.pos2key2r_��c[s|||||fS)Nr)r]r^r_r\Zkwargrrr�pos2key2dictsz.GrammarTests.testFuncdef.<locals>.pos2key2dictZtokwarg1Ztokwarg2c_s
||fS)Nr)r=�kwargsrrr�f sz#GrammarTests.testFuncdef.<locals>.fr-zf(1, *(2,3), 4)zf(1, x=2, *(3,4), x=5))�returncSsdS)Nr)r
rrrrd(sre)r
cSsdS)Nr)r
rrrrd*scWsdS)Nr)r
rrrrd,sc[sdS)Nr)r
rrrrd.s)r-cSsdS)Nr)r
r-rrrrd0s)rCrMcSsdS)Nr)rArCrMrQrrrrd2s)rCrM�e�gcWsdS)Nr)rArCrMrQrfrdrgrrrrd4srfrg�i�j�
��)rCrMrfrg�hri�krec_sdS)Nr)rArCrMrQrfrdrmrhrirgrnrrrrd7srmrncSs|S)Nr)r
rrr�null=sz&GrammarTests.testFuncdef.<locals>.nullcSsdS)Nr)r
rrrrd>scs�S)Nrr)�closurerrrdDscs�S)Nr)r
)rprrrdEscs�S)Nr)rn)rprrrdFscs�S)Nrr)rprrrdGsz
f(*g(1=2))zf(**g(1=2)))r7)r9r:)r)rrrE)rrE)rE)rr)r)rrrErF)r)rrrErF)rrErF)rrrErF)rErFrG)r)rrrErF)rErFrG)rrE)rrErFrE)r�__code__�co_varnames�str�	TypeErrorr rrr�list�__annotations__�int�floatr)r	r6r8r;r<r>r@rBrDrKrLrNrOrPrRrSrTrUrVrWrXrZr`rbrdror)rpr�testFuncdef�s4









%


%
%























0$$$
zGrammarTests.testFuncdefcCs3dd�}|j|�d�dd�}dd�}|j|�dddg�ddd�dd�d	d�}|j|�d�d
dd�}|j|dd
�d�|j|dd
d
�d�t|d�t|d�dddd�}|j|dd
�d�|j|dd
dd�d�dS)NcSsdS)Nrrrrrr�<lambda>Osz*GrammarTests.testLambdef.<locals>.<lambda>rcSsttS)N)rArQrrrrrzQscSsdd�dddgD�S)NcSsg|]}d|k�qS)rr)�.0r
rrr�
<listcomp>Rs	z>GrammarTests.testLambdef.<locals>.<lambda>.<locals>.<listcomp>rrEr���rrrrrrzRsrcSs|S)Nr)�zrrrrzTscSs|�S)Nr)r-rrrrzTscSs|�S)Nr)r
rrrrzTsrcSs|||S)Nr)r
r-r~rrrrzVsrGrErHzlambda x: x = 2zlambda (None,): Nonern�cSs|||S)Nr)r
r-rnrrrrz[srjrE�rE�
)rr)r	�l1�l2�l3�l4�l5�l6rrr�testLambdefMs!

zGrammarTests.testLambdefcCs d}~dd�}|�dS)NrcSs
d}~dS)Nrr)r
rrr�foofsz(GrammarTests.testSimpleStmt.<locals>.foor)r	r
r�rrr�testSimpleStmtcszGrammarTests.testSimpleStmtc	Csodd}d}d	}}}d
\}}}d}\}}}\}}}}t|d�t|d�dS)
NrrrErFz	x + 1 = 1z
a + 1 = b + 2)rrrE)rrrE)rrrE)rrrE�rErF)rrr�)r)	r	r
r-r~�abcrArCrM�xyzrrr�testExprStmtns$
zGrammarTests.testExprStmtcCs@dddg}|\}}}|||f}~~~~~dS)NrrrEr)r	r�r
r-r~r�rrr�testDelStmt{s
zGrammarTests.testDelStmtcCsdS)Nr)r	rrr�testPassStmt�szGrammarTests.testPassStmtcCsxPqWdS)Nr)r	rrr�
testBreakStmt�szGrammarTests.testBreakStmtc
Cs�d}x|rd}q	q	Wd}x.|sRd}y
w%d}Wq%d}Yq%Xq%W|dkrl|j|�d}x!|s�d}zwuWdd}XquW|dkr�|j|�dS)Nrrr%�okz&continue failed to continue inside tryz'continue inside try called except blockzfinally block not called)r )r	rh�msgrrr�testContinueStmt�s,		

	zGrammarTests.testContinueStmtcs#dd�fdd�}|�dS)Nrrc	s�d}xP|rX|d7}y.|r9|dkr9|d8}P|d8}w	Wq	�Yq	Xq	W|dksq|dkr~�jd�dS)Nrrz1continue then break in try/except in loop broken!)r )Zextra_burning_oil�countZ	big_hippo)r	rr�
test_inner�s	


z9GrammarTests.test_break_continue_loop.<locals>.test_innerr)r	r�r)r	r�test_break_continue_loop�s
z%GrammarTests.test_break_continue_loopcCs9dd�}dd�}|�|�}t|d�dS)NcSsdS)Nrrrrr�g1�sz#GrammarTests.testReturn.<locals>.g1cSsdS)Nrrrrrr�g2�sz#GrammarTests.testReturn.<locals>.g2zclass foo:return 1)r)r	r�r�r
rrr�
testReturn�s
	zGrammarTests.testReturncCst|d�dS)Nzclass foo:yield 1)r)r	rrr�	testYield�szGrammarTests.testYieldcCsHytd��Wntk
r$YnXy
t�Wntk
rCYnXdS)Nzjust testing)�RuntimeError�KeyboardInterrupt)r	rrr�	testRaise�s


zGrammarTests.testRaisecCs�ddl}ddl}ddl}ddlm}ddlm}ddlm}m}ddlm}m}ddlm}m}dS)Nr)�time)�path�argv)rr�r�r�)r	rr�r�r�rrr�
testImport�szGrammarTests.testImportcCsdS)Nr)r	rrr�
testGlobal�szGrammarTests.testGlobalcs%d�d���fdd�}dS)NrcsdS)Nrr)r
r-rrrd�sz$GrammarTests.testNonlocal.<locals>.fr)r	rdr)r
r-r�testNonlocal�szGrammarTests.testNonlocalcCs�dst�dstd��dd�s0t�dsHtdd���yds]td��Wn<tk
r�}z|j|jdd�WYdd}~XnX|jd�dS)NrcSs|S)Nr)r
rrrrz�sz)GrammarTests.testAssert.<locals>.<lambda>cSs|dS)Nrr)r
rrrrz�srr�z%AssertionError not raised by assert 0)�AssertionErrorrr=r )r	rfrrr�
testAssert�s*zGrammarTests.testAssertcCsdS)Nr)r	rrr�testIfszGrammarTests.testIfcCs d}d}|j|d�dS)Nrr)r)r	r
rrr�	testWhileszGrammarTests.testWhilecCs�xd
D]}qWxfD]\}}}qWGdd�d�}d}x|d�D]}||}qQW|dkr~|jd	�g}x'ddd
gD]\}|j|�q�W|j|dddg�dS)NrrrEc@s4eZdZdd�Zdd�Zdd�ZdS)z%GrammarTests.testFor.<locals>.SquarescSs||_g|_dS)N)�max�sofar)r	r�rrr�__init__#s	z.GrammarTests.testFor.<locals>.Squares.__init__cSs
t|j�S)N)r+r�)r	rrr�__len__&sz-GrammarTests.testFor.<locals>.Squares.__len__cSspd|ko|jkns%t�t|j�}x.||krd|jj||�|d}q7W|j|S)Nrr)r��
IndexErrorr+r��append)r	rh�nrrr�__getitem__'sz1GrammarTests.testFor.<locals>.Squares.__getitem__N)r1r2r3r�r�r�rrrr�Squares"sr�rrjizfor over growing sequence)rrrE)r)r)rE)r r��assertEqual)r	rhrirnr�r�r
�resultrrr�testFors

zGrammarTests.testForc5CsyddWntk
r YnXyddWnatk
rAYnPtk
re}zWYdd}~Xn,tk
r�}zWYdd}~XnYnXyddWntttfk
r�YnXyddWn.tttfk
r�}zWYdd}~XnXzWdXdS)Nrr)�ZeroDivisionError�EOFErrorrtr�)r	r�rrr�testTry8s2

zGrammarTests.testTrycCsdS)Nr)r	rrr�	testSuiteOszGrammarTests.testSuitecCshdsdrdrdsdrds&dr9dr9dr9drEdsddrWdrWdsddrddrddS)Nrr)r	rrr�testTest^s+zGrammarTests.testTestcCs�ddk}ddkrddkr$ddkr0ddkr<ddkrHddkrTddkr`ddk	rldfkrxdfkr�ddko�dko�dko�dko�dko�dko�dko�dko�dko�dk	nr�dS)Nrr)r	r
rrr�testComparisonistzGrammarTests.testComparisoncCsd}d}d}dS)Nrrrrr)r	r
rrr�testBinaryMaskOpszszGrammarTests.testBinaryMaskOpscCsd}d}d}dS)Nrrrrrr)r	r
rrr�testShiftOpsszGrammarTests.testShiftOpscCsd}d}d}d}dS)	Nrrrr}rrrrr)r	r
rrr�testAdditiveOps�szGrammarTests.testAdditiveOpscCsd}d}d}d}dS)Nrrg�?rg�?g�?gr)r	r
rrr�testMultiplicativeOps�sz"GrammarTests.testMultiplicativeOpscCs"d}d}d}d}d}dS)Nrrr}���r�rr}rr}r�r}r}r}g�rgr}rr}r}g�?r)r	r
rrr�testUnaryOps�s
zGrammarTests.testUnaryOpsc	Cs8ddl}ddl}|jd}|j�}|jdj�}d}|d}|d
}|dd�}|dd�}|dd�}|dd�}|dd�}|dd�}|dd�}i}d|d<d|d<d|d<d|d<t|�}|jd	d
d��|jt|�d�dS)Nrr�Z01234rrGrFrErrYcSst|t�r|SfS)N)�
isinstance�tuple)r
rrrrz�sz,GrammarTests.testSelectors.<locals>.<lambda>z[1, (1,), (1, 2), (1, 2, 3)]r}���r}������)r)rr)rrrE)rr�r��modulesru�sortrrs)	r	rr�rMr
rAr!rQ�Lrrr�
testSelectors�s,






zGrammarTests.testSelectorscCsEd}dpdpd}dp'dp'dddf}g}dg}dpQdpQdg}dpfdpfdddg}g}i}ddi}ddi}dp�ddp�di}ddddi}ddddi}ddddddddd	d
ddi}dh}ddh}dddh}dddh}|}d
}d}dS)NrrrEZoner9ZthreeZfourrFZfiverGZsixrHr
�{r)r	r
rrr�	testAtoms�s,	*	zGrammarTests.testAtomsc	Cs�Gdd�d�}Gdd�d�}Gdd�d|�}Gdd�d|�}Gd	d
�d
|||�}Gdd�d�}d
d�}|Gdd�d��}dS)Nc@seZdZdS)z$GrammarTests.testClassdef.<locals>.BN)r1r2r3rrrr�B�sr�c@seZdZdS)z%GrammarTests.testClassdef.<locals>.B2N)r1r2r3rrrr�B2�sr�c@seZdZdS)z%GrammarTests.testClassdef.<locals>.C1N)r1r2r3rrrr�C1�sr�c@seZdZdS)z%GrammarTests.testClassdef.<locals>.C2N)r1r2r3rrrr�C2�sr�c@seZdZdS)z$GrammarTests.testClassdef.<locals>.DN)r1r2r3rrrr�D�sr�c@s4eZdZdd�Zdd�Zdd�ZdS)z$GrammarTests.testClassdef.<locals>.CcSsdS)Nr)r	rrr�meth1�sz*GrammarTests.testClassdef.<locals>.C.meth1cSsdS)Nr)r	�argrrr�meth2�sz*GrammarTests.testClassdef.<locals>.C.meth2cSsdS)Nr)r	r<r>rrr�meth3�sz*GrammarTests.testClassdef.<locals>.C.meth3N)r1r2r3r�r�r�rrrr�C�sr�cSs|S)Nr)r
rrr�class_decorator�sz2GrammarTests.testClassdef.<locals>.class_decoratorc@seZdZdS)z$GrammarTests.testClassdef.<locals>.GN)r1r2r3rrrr�G�sr�r)	r	r�r�r�r�r�r�r�r�rrr�testClassdef�szGrammarTests.testClassdefcCsBdddg}|jdd�|D�ddddddi�dS)NrrrEcSsi|]}|d|�qS)rr)r{rhrrr�
<dictcomp>�s	z.GrammarTests.testDictcomps.<locals>.<dictcomp>rF)r�)r	�numsrrr�
testDictcomps�szGrammarTests.testDictcompscsedddddg}dddg�d	d
dg}�jdd
�|D�dddg��jdd
�|D�dddddg��jdd
�|D�dddg��j�fdd
�|D�d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;g��j�fdd
�|D�d<d=d>d?d@dAdBdCdDdEg
��jdd
�td�D�dgddgdddgddddgdddddgg�dd�}�j||�dddg��fdd �}|�t�d!�t�d"�dFdGdHg}dIdJdKg�dLdMdNdOg���fd,d
�|D�}�j|dPdQdRdSg�dS)TNrrrErFrG�Apple�Banana�Coconutz  Applez Banana zCoco  nut  cSsg|]}|j��qSr)�strip)r{r!rrrr|�s	z.GrammarTests.testListcomps.<locals>.<listcomp>z	Coco  nutcSsg|]}d|�qS)rEr)r{r
rrrr|�s	rHrrl�cSs"g|]}|dkr|�qS)rr)r{r
rrrr|�s	cs)g|]}�D]}||f�qqSrr)r{rhr!)�strsrrr|�s	cs6g|],}dd��D�D]}||f�qqS)cSs"g|]}d|kr|�qS)r�r)r{rdrrrr|s	z9GrammarTests.testListcomps.<locals>.<listcomp>.<listcomp>r)r{rhr!)r�rrr|s	cSs"g|]}dd�|��qS)cs!�fdd�t�d�D�S)Ncsg|]}�|�qSrr)r{rh)rArrr|s	zKGrammarTests.testListcomps.<locals>.<listcomp>.<lambda>.<locals>.<listcomp>r)�range)rAr)rArrzsz7GrammarTests.testListcomps.<locals>.<listcomp>.<lambda>r)r{rirrrr|s	���@�cSsdd�|D�S)NcSs8g|].}|dkrd|ko/dkn�qS)rrrEr)r{r
rrrr|	s	zDGrammarTests.testListcomps.<locals>.test_in_func.<locals>.<listcomp>r)�lrrr�test_in_funcsz0GrammarTests.testListcomps.<locals>.test_in_funcFcsE�jdd�dddgD�ddgddgddgg�dS)	NcSs-g|]#}dd�||dgD��qS)cSsg|]}|�qSrr)r{r-rrrr|s	zTGrammarTests.testListcomps.<locals>.test_nested_front.<locals>.<listcomp>.<listcomp>rr)r{r
rrrr|s	zIGrammarTests.testListcomps.<locals>.test_nested_front.<locals>.<listcomp>rrErGrrFrH)r�r)r	rr�test_nested_front
sz5GrammarTests.testListcomps.<locals>.test_nested_frontz"[i, s for i in nums for s in strs]z[x if y]�Boeing�Ford�
Macdonaldsrj�Airlinerr�Engine��Cheeseburgercs`g|]V\}}�D]C\}}�D]0\}}||kr&||kr&||f�q&qqSrr)r{ZsnoZsnameZpnoZpnameZsp_snoZsp_pno)�parts�suppartrrr|'s		)rr�)rr�)rr�)rr�)rr�)rr�)rEr�)rEr�)rEr�)rFr�)rFr�)rFr�)rGr�)rGr�)rGr�)rr�)rr�)rr�)rr�)rEr�)rEr�)rFr�)rFr�)rGr�)rGr�)rr�)rr�)rEr�)rjr�)rr�)r�r�)rrj)rr)rr)rEr�)r�r�)r�r�)r�r�)r�r�)r�r�r)r	r�Zspcsr�r�Z	suppliersr
r)r�r	r�r�r�
testListcomps�sF&,&				
C

		
zGrammarTests.testListcompscs�dd�td�D�}|jt|�dd�td�D��yt|�|jd�Wntk
rqYnXd�y4�fdd��D�}t|�|jd	�Wntk
r�YnX|jtd
d�dD��dd�dD��|jtd
d�dD��dd�dD��dd�td�D��dd�dd��D�D�}|jt|�tdd�td�D���|jtdd�td�D��tdd�td�D���|jtdd�td�D��tdd�td�D���|jtdd�dd�td�D�D��tdd�td�D���|jtdd�dd�dd�td�D�D�D��tdd�td�D���|jtdd�d d�d!d�td�D�D�D��td"d�td�D���|jtd#d�d$d�d%d�td�D�D�D��td&d�td�D���|jtd'd�d(d�d)d�td�D�D�D��d*�t|d+�t|d,�dS)-Ncss(|]}dd�td�D�VqdS)cSsg|]}|�qSrr)r{r
rrrr|3s	z6GrammarTests.testGenexps.<locals>.<genexpr>.<listcomp>rjN)r�)r{r
rrr�	<genexpr>3sz+GrammarTests.testGenexps.<locals>.<genexpr>rcSsg|]}|�qSrr)r{r
rrrr|4s	z,GrammarTests.testGenexps.<locals>.<listcomp>rjz&should produce StopIteration exceptionc3s|]}�VqdS)Nr)r{rQ)rArrr�=szshould produce TypeErrorcss(|]}dD]}||fVq
qdS)�abcdNr)r{r
r-rrrr�Csr�cSs)g|]}dD]}||f�qqS)r�r)r{r
r-rrrr|Cs	css(|]}dD]}||fVq
qdS)�xyNr)r{r
r-rrrr�DsZabcSs)g|]}dD]}||f�qqS)r�r)r{r
r-rrrr|Ds	cSsg|]}|�qSrr)r{r
rrrr|Fs	css|]}|VqdS)Nr)r{r
rrrr�Gscss|]}|VqdS)Nr)r{r-rrrr�GscSsg|]}|�qSrr)r{r
rrrr|Hs	css|]}|dVqdS)rNr)r{r
rrrr�JscSsg|]}|d�qS)rr)r{r
rrrr|Js	css#|]}|dr||VqdS)rNr)r{r
rrrr�KscSs$g|]}|dr||�qS)rr)r{r
rrrr|Ks	css|]}|VqdS)Nr)r{r
rrrr�Lscss|]}|VqdS)Nr)r{r-rrrr�LscSsg|]}|�qSrr)r{r
rrrr|Ls	css|]}|VqdS)Nr)r{r
rrrr�Mscss|]}|VqdS)Nr)r{r-rrrr�Mscss|]}|VqdS)Nr)r{r~rrrr�MscSsg|]}|�qSrr)r{r
rrrr|Ms	css|]}|VqdS)Nr)r{r
rrrr�NscSsg|]}|�qSrr)r{r-rrrr|Ns	css|]}|VqdS)Nr)r{r~rrrr�NscSsg|]}|�qSrr)r{r
rrrr|Ns	css|]}|VqdS)TNr)r{r
rrrr�Oscss|]}|VqdS)Nr)r{r-rrrr�Oscss|]}|VqdS)TNr)r{r~rrrr�OscSsg|]}|�qSrr)r{r
rrrr|Os	css|]}|VqdS)TNr)r{r
rrrr�Pscss|]}dr|VqdS)FNr)r{r-rrrr�Pscss|]}|VqdS)TNr)r{r~rrrr�Psrzfoo(x for x in range(10), 100)zfoo(100, x for x in range(10)))	r�r��nextr �
StopIterationrtru�sumr)r	rgrCr)rAr�testGenexps1s8)



00 /BBO\\\C
zGrammarTests.testGenexpscsjd�dd�t��D�}d�|jtt|��d�d�d���fdd�t��D�}d�d�|jdd	�td�D�t|��|jd
d	�td�D�dddg�|jtd
d�td�D��dddg�|jdd	�dddgD�dddg�|jtdd�dddgD��dddg�dS)Nrjcss|]}|VqdS)Nr)r{rhrrrr�Vsz9GrammarTests.testComprehensionSpecials.<locals>.<genexpr>rGFc3s4|]*}�rt��D]}||fVqqdS)N)r�)r{rhri)�tr
rrr�ZsTcSs/g|]%}td�D]}||f�qqS)rG)r�)r{rhrirrrr|\s	z:GrammarTests.testComprehensionSpecials.<locals>.<listcomp>cSs*g|] }|dr|dr|�qS)rrEr)r{r
rrrr|`s	rrIcss)|]}|dr|dr|VqdS)rrENr)r{r
rrrr�ascSsg|]\}|�qSrr)r{r
rrrr|ds	rFrHcss|]\}|VqdS)Nr)r{r
rrrr�esrJr)rF)rG)rH)rI)rJ)r)r�r�r+ru)r	rgr)r�r
r�testComprehensionSpecialsTs"),2/z&GrammarTests.testComprehensionSpecialscACs�Gdd�dt�}|��WdQRX|��}WdQRX|��
\}}WdQRX|��|��WdQRXWdQRX|��}|��}WdQRXWdQRX|��}|��WdQRXWdQRXdS)Nc@s(eZdZdd�Zdd�ZdS)z1GrammarTests.test_with_statement.<locals>.managercSsdS)Nrr)rrr)r	rrr�	__enter__isz;GrammarTests.test_with_statement.<locals>.manager.__enter__cWsdS)Nr)r	r=rrr�__exit__ksz:GrammarTests.test_with_statement.<locals>.manager.__exit__N)r1r2r3r�r�rrrr�managerhsr�)�object)r	r�r
r-rrr�test_with_statementgs
z GrammarTests.test_with_statementcCsDdd�}|jdd�dd�dd�fD�dg�|jd	d�d
d�dd�fD�dg�|jd
n|dd�d
�|jdr�|dd�nd
d
�|jdr�d
o�dndd�|jdr�d
o�dndd�|jd
o
dndd�|jdr5dp8|dd�ndd�|jdpf|dd�n|dd�d�|jdp�d
n|dd�d
�|jd
ndd�|jdr�d
ndd�|jdndd�|jdndd
�|jdndd�|jdndd�|jdr6ddkndd�dS) NcSstt�|S)z@helper to check that evaluation of expressions is done correctly)�printr
)r�Zretrrr�
_checkeval}s
z/GrammarTests.testIfElseExpr.<locals>._checkevalcSs"g|]}|�r|��qSrr)r{r
rrrr|�s	z/GrammarTests.testIfElseExpr.<locals>.<listcomp>cSsdS)NTrrrrrrz�sz-GrammarTests.testIfElseExpr.<locals>.<lambda>cSsdS)NFrrrrrrz�sTcSs(g|]}|d�r|d��qS)Fr)r{r
rrrr|�s	cSs|r
dSdS)NFTr)r
rrrrz�scSs|r
dSdS)NTFr)r
rrrrz�srrGzcheck 1rzcheck 2rHzcheck 3rrEzcheck 4zcheck 5zcheck 6FrIrFrlrIrGrlg@)r�)r	rrrr�testIfElseExpr{s$22%""+.%zGrammarTests.testIfElseExprN))r1r2r3r5ryr�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�r�r�r�r�r�rrrrrrr4�sL�
	

#?#r4cCsttt�dS)N)rrr4rrrr�	test_main�sr�__main__)
Ztest.supportrrZunittestrZTestCaserr4rr1rrrr�<module>s
u���