<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</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้   T้2   ้๔  ้่  )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      