HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/python38/lib/python3.8/idlelib/idle_test/__pycache__/test_hyperparser.cpython-38.pyc
U

�i�_z#�@sxdZddlmZddlZddlmZddlmZmZddl	m
Z
Gdd�d�ZGd	d
�d
ej�Z
edkrtejdd
�dS)zTest hyperparser, coverage 98%.�)�HyperParserN)�requires)�Tk�Text)�EditorWindowc@s eZdZdd�ZejZejZdS)�DummyEditwincCs"||_d|_d|_d|_d|_dS)N��>>>)�2i�i�)�textZindentwidthZtabwidth�prompt_last_lineZnum_context_lines)�selfr�r�A/opt/python38/lib/python3.8/idlelib/idle_test/test_hyperparser.py�__init__
s
zDummyEditwin.__init__N)�__name__�
__module__�__qualname__rrZ_build_char_in_string_funcZis_char_in_stringrrrrr	src@sxeZdZdZedd��Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�HyperParserTestu#"""This is a module docstring"""
# this line is a comment
x = "this is a string"
y = 'this is also a string'
l = [i for i in range(10)]
m = [py*py for # comment
       py in l]
x.__len__
z = ((r'asdf')+('a')))
[x for x in
for = False
cliché = "this is a string with unicode, what a cliché"cCs6td�t�|_|j��t|j�|_t|j�|_dS)NZgui)rr�rootZwithdrawrrr�editwin��clsrrr�
setUpClass%s

zHyperParserTest.setUpClasscCs|`|`|j��|`dS)N)rrrZdestroyrrrr�
tearDownClass-s
zHyperParserTest.tearDownClasscCs|j�d|j�dS)N�insert)rr�code�r
rrr�setUp3szHyperParserTest.setUpcCs|j�dd�d|j_dS)N�1.0�endr	)r�deleterrrrrr�tearDown6szHyperParserTest.tearDowncCst|j|�S)z>
        Return a parser object with index at 'index'
        )rr)r
�indexrrr�
get_parser:szHyperParserTest.get_parserc	Cs�|�t�� }|j�ddd�|�d�}W5QRX|�dt|j��d|j_	|�d�}|�
|j|j�dd��|j�
d|j�dd�d�|�d	�}d
S)z6
        test corner cases in the init method
        Zconsolerz1.endz1.5�precedes�r �z54.5N)�assertRaises�
ValueErrorrZtag_addr$�assertIn�str�	exceptionrr�assertEqualZrawtext�getr)r
�ve�prrr�	test_init@s
zHyperParserTest.test_initcCs�|j}|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���dS)Nrz1.4z2.3z3.3z3.7z4.6z12.54)r$�assertFalseZis_in_string�
assertTrue�r
r.r0rrr�test_is_in_stringTsz!HyperParserTest.test_is_in_stringcCs�|j}|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���dS)Nrz1.1z2.5z3.4z3.6z4.14)r$r3Z
is_in_coder2r4rrr�test_is_in_codefszHyperParserTest.test_is_in_codecCs�|j}dd�}dd�}|d�}|�||��|�||��|d�}|�||�d�|�||�||��|d�}|�||�d	�|�||�||��|d
�}|�||�d�|�||��|d�}|�||��|�||��dS)
NcSs|jdd�S)NF�Z	mustclose�Zget_surrounding_brackets��parserrrr�without_mustcloseyszGHyperParserTest.test_get_surrounding_bracket.<locals>.without_mustclosecSs|jdd�S)NTr7r8r9rrr�with_mustclose~szDHyperParserTest.test_get_surrounding_bracket.<locals>.with_mustclosez3.2z5.6)z5.4�5.25z5.23)z5.21z5.24z6.15)z6.4z6.endz9.end)r$ZassertIsNoneZassertTupleEqual)r
r.r;r<r0rrr�test_get_surrounding_bracketvs$z,HyperParserTest.test_get_surrounding_bracketc	Cs�|j}|d�}|�|��d�|d�}|�t��}|��W5QRX|�dt|j��|d�}|�|��d�|d�}|�|��d�|d	�}|�|��d
�|d�}|�|��d�|d�}|�|��d
�|d�}|�|��d�|d�}|�t��}|��W5QRX|�dt|j��|d�}|�|��d
�|d�}|�|��d
�|d�}|�|��d
�|d�}|�|��d
�|d�}|�|��d�|d�}|�|��d�dS)Nz4.2zy z4.7zis inside a coder=z	range(10)z6.7�pyz6.8r&z7.9z8.endz	x.__len__z9.13zr'asdf'z9.17z10.0z10.6z10.11z11.3z11.11�Falsez12.6�cliché)r$r-Zget_expressionr(r)r*r+r,)r
r.r0r/rrr�test_get_expression�sFz#HyperParserTest.test_get_expressioncCs�dd�}|�|d��|�|d��|�|d��|�|d��|�|d��|�|d��|�|d	��|�|d
��|�|d��|�|d��|�|d
��|�|d��|�|d��|�|d��|�|d��|�|d��|�|d��|�t�ddd�td��|�t�ddd�td��|�t�ddd�td��|�|d��|�|d��|�|d��|�|d��|�|d��|�|d ��|�|d!��|�|d"��dS)#NcSsJt�|dt|��}|t|�kr"dS|dkr.dSd�|t|��}t|��dS)NrTFz'Unexpected result: {} (expected 0 or {})r�_eat_identifier�len�format�	Exception)�	candidate�result�err_msgrrr�is_valid_id�s�z8HyperParserTest.test_eat_identifier.<locals>.is_valid_idZ2notidZvalid_idZ	_valid_idZ	valid_id_Z
_2valid_id�Truer@�None�for�import�returnZclicherAua٢Z2au٢aua²z+ varr��varz+varr'z.var�+� �:�?�^�\�"z
"a string")r2r3r-rrCrD)r
rJrrr�test_eat_identifier�s:
z#HyperParserTest.test_eat_identifiercCs$tj}tdd�D�]}|�|d|d|�|�|�|d|d|�|�|�|dd|dd|�|�|�|dd|dd|�|�|�|dd|dd|�|�|�|d|ddd|�|�|�|d|d|�d�|�|dd|dd|�d�|�|dd|dd|�d�qdS)N���ar�é�2rR)rrC�ranger-)r
Zeat_id�lengthrrr�#test_eat_identifier_various_lengthss     z3HyperParserTest.test_eat_identifier_various_lengthsN)rrrr�classmethodrrrr"r$r1r5r6r>rBrYrarrrrrs �

!49r�__main__�)�	verbosity)�__doc__Zidlelib.hyperparserrZunittestZtest.supportr�tkinterrrZidlelib.editorrrZTestCaserr�mainrrrr�<module>s