<!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>

]#                 @   s   d  d l  Z  d  d l m Z d  d l m Z m Z d  d l m Z d  d l m	 Z	 Gd d   d  Z
 Gd d	   d	 e  j  Z e d
 k r e  j d d  d S)    N)requires)TkText)EditorWindow)HyperParserc               @   s.   e  Z d  Z d d   Z e j Z e j Z d S)DummyEditwinc             C   s1   | |  _  d |  _ d |  _ d |  _ d |  _ d  S)N   T2       )r	   r
   r   )textZindentwidthZtabwidthcontext_use_ps1Znum_context_lines)selfr    r   5/opt/alt/python35/lib64/python3.5/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               @   s   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   sK   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   setUp2   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   tearDown5   s    zHyperParserTest.tearDownc             C   s   t  |  j |  S)N)r   r   )r   indexr   r   r   
get_parser9   s    zHyperParserTest.get_parserc             C   s   |  j  t  , } |  j j d d d  |  j d  } Wd  QRX|  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)
NZconsolez1.0z1.endz1.5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_stringS   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"   r0   Z
is_in_coder/   )r   r+   r-   r   r   r   test_is_in_codee   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)N	mustcloseF)get_surrounding_brackets)parserr   r   r   without_mustclosex   s    zGHyperParserTest.test_get_surrounding_bracket.<locals>.without_mustclosec             S   s   |  j  d d  S)Nr3   T)r4   )r5   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)r8   r9   )r:   r;   )r<   r=   )r"   ZassertIsNoneZassertTupleEqual)r   r+   r6   r7   r-   r   r   r   test_get_surrounding_bracketu   s$    	z,HyperParserTest.test_get_surrounding_bracketc             C   sW  |  j  } | d  } |  j | j   d  | d  } |  j t   } | j   Wd  QRX|  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   Wd  QRX|  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   sZ  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   si   t  j |  d t |    } | t |   k r1 d S| d k rA d Sd j | t |    } t |   d  S)Nr   TFz'Unexpected result: {} (expected 0 or {})r   _eat_identifierlenformat	Exception)	candidateresult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TruerA   NoneforimportreturnZclicheu   clichéu   a٢Z2au   ٢au   a²z+ varr      varz+varr$   z.var+ :?^\"z
"a string")r/   r0   r*   r   rC   rD   )r   rJ   r   r   r   test_eat_identifier   s:    %%%z#HyperParserTest.test_eat_identifierc             C   sw  t  j } xgt d d  D]V} |  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 Wd  S)N      ar      é2rR   )r   rC   ranger*   )r   Zeat_id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.   r1   r2   r>   rB   rY   ra   r   r   r   r   r      s   !49r   __main__	verbosity   )ZunittestZtest.supportr   tkinterr   r   Zidlelib.EditorWindowr   Zidlelib.HyperParserr   r   ZTestCaser   r   mainr   r   r   r   <module>   s   