£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
3
 fx#                 @   sx   d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 G dd dZG d	d
 d
ejZedkrtejdd dS )zTest hyperparser, coverage 98%.    )HyperParserN)requires)TkText)EditorWindowc               @   s    e Zd Zdd ZejZejZdS )DummyEditwinc             C   s"   || _ d| _d| _d| _d| _d S )N   T2       )r	   r
   r   )textZindentwidthZtabwidthcontext_use_ps1Znum_context_lines)selfr    r   G/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_hyperparser.py__init__
   s
    zDummyEditwin.__init__N)__name__
__module____qualname__r   r   Z_build_char_in_string_funcZis_char_in_stringr   r   r   r   r   	   s   r   c               @   sx   e Zd ZdZedd Zedd Zdd Zdd	 Zd
d Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )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é"c             C   s6   t d t | _| jj  t| j| _t| j| _d S )NZgui)r   r   rootZwithdrawr   r   r   editwin)clsr   r   r   
setUpClass%   s
    
zHyperParserTest.setUpClassc             C   s   | ` | `| jj  | `d S )N)r   r   r   Zdestroy)r   r   r   r   tearDownClass-   s    
zHyperParserTest.tearDownClassc             C   s   | j jd| j d S )Ninsert)r   r   code)r   r   r   r   setUp3   s    zHyperParserTest.setUpc             C   s   | j jdd d| j_d S )Nz1.0endT)r   deleter   r   )r   r   r   r   tearDown6   s    zHyperParserTest.tearDownc             C   s   t | j|S )z>
        Return a parser object with index at 'index'
        )r   r   )r   indexr   r   r   
get_parser:   s    zHyperParserTest.get_parserc             C   s   | j t }| jjddd | jd}W dQ R X | jdt|j d| j_	| jd}| j
|j| jjdd | jjd| jjddd	  | jd
}dS )z6
        test corner cases in the init method
        Zconsolez1.0z1.endz1.5NZprecedesFr      z54.5)assertRaises
ValueErrorr   Ztag_addr"   assertInstr	exceptionr   r   assertEqualZrawtextgetr   )r   vepr   r   r   	test_init@   s    
zHyperParserTest.test_initc             C   s   | j }|d}| j|j  |d}| j|j  |d}| j|j  |d}| j|j  |d}| j|j  |d}| j|j  |d}| j|j  d S )Nz1.0z1.4z2.3z3.3z3.7z4.6z12.54)r"   assertFalseZis_in_string
assertTrue)r   r*   r,   r   r   r   test_is_in_stringT   s    z!HyperParserTest.test_is_in_stringc             C   s   | j }|d}| j|j  |d}| j|j  |d}| j|j  |d}| j|j  |d}| j|j  |d}| j|j  d S )Nz1.0z1.1z2.5z3.4z3.6z4.14)r"   r/   Z
is_in_coder.   )r   r*   r,   r   r   r   test_is_in_codef   s    zHyperParserTest.test_is_in_codec             C   s   | j }dd }dd }|d}| j|| | j|| |d}| j||d | j|||| |d	}| j||d | j|||| |d}| j||d | j|| |d}| j|| | j|| d S )Nc             S   s   | j ddS )NF)	mustclose)get_surrounding_brackets)parserr   r   r   without_mustclosey   s    zGHyperParserTest.test_get_surrounding_bracket.<locals>.without_mustclosec             S   s   | j ddS )NT)r2   )r3   )r4   r   r   r   with_mustclose~   s    zDHyperParserTest.test_get_surrounding_bracket.<locals>.with_mustclosez3.2z5.65.45.25z5.235.215.24z6.156.46.endz9.end)r7   r8   )r9   r:   )r;   r<   )r"   ZassertIsNoneZassertTupleEqual)r   r*   r5   r6   r,   r   r   r   test_get_surrounding_bracketv   s$    z,HyperParserTest.test_get_surrounding_bracketc             C   s  | j }|d}| j|j d |d}| jt}|j  W d Q R X | jdt|j |d}| j|j d |d}| j|j d |d	}| j|j d
 |d}| j|j d |d}| j|j d |d}| j|j d |d}| jt}|j  W d Q R X | jdt|j |d}| j|j d
 |d}| j|j d
 |d}| j|j d
 |d}| j|j d
 |d}| j|j d |d}| j|j d d S )Nz4.2zy z4.7zis inside a codez5.25z	range(10)z6.7pyz6.8 z7.9z8.endz	x.__len__z9.13zr'asdf'z9.17z10.0z10.6z10.11z11.3z11.11Falsez12.6u   cliché)r"   r)   Zget_expressionr$   r%   r&   r'   r(   )r   r*   r,   r+   r   r   r   test_get_expression   sF    z#HyperParserTest.test_get_expressionc             C   s  dd }| j |d | j|d | j|d | j|d | j|d | j|d | j|d	 | j|d
 | j |d | j |d | j |d | j|d | j|d | j|d | j |d | j |d | j |d | jtjdddtd | jtjdddtd | jtjdddtd | j |d | j |d | j |d | j |d | j |d | j |d  | j |d! | j |d" d S )#Nc             S   sJ   t j| dt| }|t| kr"dS |dkr.dS dj|t| }t|d S )Nr   TFz'Unexpected result: {} (expected 0 or {})r   _eat_identifierlenformat	Exception)	candidateresultZerr_msgr   r   r   is_valid_id   s    z8HyperParserTest.test_eat_identifier.<locals>.is_valid_idZ2notidZvalid_idZ	_valid_idZ	valid_id_Z
_2valid_idTruer@   NoneforimportreturnZclicheu   clichéu   a٢Z2au   ٢au   a²z+ varr      varz+varr#   z.var+ :?^\"z
"a string")r.   r/   r)   r   rB   rC   )r   rH   r   r   r   test_eat_identifier   s:    z#HyperParserTest.test_eat_identifierc             C   s*  t j}xtddD ]}| j|d| d|| | j|d| d|| | j|dd|d   d|| | j|dd|d   d|| | j|dd|d   d|| | j|d|d  d d|| | j|d| d|d | j|dd|d   d|d | j|dd|d   d|d qW d S )N      ar      é2rP   )r   rB   ranger)   )r   Zeat_idZlengthr   r   r   #test_eat_identifier_various_lengths  s         z3HyperParserTest.test_eat_identifier_various_lengthsN)r   r   r   r   classmethodr   r   r   r    r"   r-   r0   r1   r=   rA   rW   r^   r   r   r   r   r      s   !49r   __main__   )	verbosity)__doc__Zidlelib.hyperparserr   ZunittestZtest.supportr   Ztkinterr   r   Zidlelib.editorr   r   ZTestCaser   r   mainr   r   r   r   <module>   s      