Your IP : 216.73.217.129


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_asdl_parser.cpython-35.pyc



��Yf��@s�dZddlZddlZddlmZddlZddlZddlZej	�smej
d��eeee���Zej
jed�ZGdd�dej�Zedkr�ej�dS)	z+Tests for the asdl parser in Parser/asdl.py�N)�dirnamez'test irrelevant for an installed PythonZParserc@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)�TestAsdlParsercCs�tjjdt�tjjdtjjtd��}|j	�|_
|j
jtjjtd��|_|j
|j
j|j�d�dS)Nr�asdlzasdl.pyzPython.asdlzModule validation failed)�sys�path�insert�
parser_dir�	importlib�	machinery�SourceFileLoader�os�join�load_moduler�parse�mod�
assertTrueZcheck)�cls�loader�r�:/opt/alt/python35/lib64/python3.5/test/test_asdl_parser.py�
setUpClasss	$zTestAsdlParser.setUpClasscCstjd=dS)Nr)rr)rrrr�
tearDownClass!szTestAsdlParser.tearDownClasscCs+tj|_tj|_|jj|_dS)N)rrr�types)�selfrrr�setUp%szTestAsdlParser.setUpcCsS|j|jjd�|jd|j�|jd|j�|jd|j�dS)N�Python�stmt�exprr)�assertEqualr�nameZassertInr)rrrr�test_module+szTestAsdlParser.test_modulecCs�|jj}|j|d|jj�|j|dj|jj�|j|jd|jj�|j|jd|jj�dS)NrZwithitem�alias)	r�dfns�assertIsInstancerZType�valueZSumrZProduct)rZdefsrrr�test_definitions1s
zTestAsdlParser.test_definitionscCs'|jd}|jt|�d�dS)Nr!zGProduct([Field(identifier, name), Field(identifier, asname, opt=True)]))rr�str)rr!rrr�test_product9s
	zTestAsdlParser.test_productcCsd|jd}|jt|j�d�|jt|jd�d�|jt|jd�d�dS)Nr�rzField(int, lineno)�zField(int, col_offset))rr�len�
attributesr&)rrrrr�test_attributes?s
zTestAsdlParser.test_attributescCsX|jd}|jt|j�d�|jt|j�d�|jd}|j||jj�|jt|j�d�|jd}|j|jd�|j|j	d�|j
|j�|jd}|j|jd�|j|j	d	�|j
|j�|jd}|j|jd
�|j|j	d�|j|j�|j
|j
�dS)NZ
excepthandlerr)r(r�r�typeZ
identifierrrZbody)rrr*r+r#rZConstructor�fieldsr.rrZoptZassertFalse�seq)rZehandler�consZf0�f1�f2rrr�test_constructor_fieldsEs&




z&TestAsdlParser.test_constructor_fieldscCsYGdd�d|jj�}|�}|j|jd�|j|jdddg�dS)NcsReZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Z�S)z2TestAsdlParser.test_visitor.<locals>.CustomVisitorcst�j�g|_dS)N)�super�__init__�names_with_seq)r)�	__class__rrr6`s
z;TestAsdlParser.test_visitor.<locals>.CustomVisitor.__init__cSs%x|jD]}|j|�q
WdS)N)r"�visit)rrZdfnrrr�visitModuledsz>TestAsdlParser.test_visitor.<locals>.CustomVisitor.visitModulecSs|j|j�dS)N)r9r$)rr.rrr�	visitTypehsz<TestAsdlParser.test_visitor.<locals>.CustomVisitor.visitTypecSs%x|jD]}|j|�q
WdS)N)rr9)r�sum�trrr�visitSumksz;TestAsdlParser.test_visitor.<locals>.CustomVisitor.visitSumcSs4x-|jD]"}|jr
|jj|j�q
WdS)N)r/r0r7�appendr)rr1�frrr�visitConstructoros	zCTestAsdlParser.test_visitor.<locals>.CustomVisitor.visitConstructor)�__name__�
__module__�__qualname__r6r:r;r>rArr)r8r�
CustomVisitor_s
rErZModuleZInteractiveZSuite)rZVisitorBaser9rrr7)rrE�vrrr�test_visitor^s	zTestAsdlParser.test_visitorN)
rBrCrD�classmethodrrrr r%r'r,r4rGrrrrrs
r�__main__)�__doc__�importlib.machineryr	rZos.pathrr�	sysconfigZunittest�is_python_buildZSkipTest�__file__Zsrc_baserr
rZTestCaserrB�mainrrrr�<module>sf