JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrB  fz#@sxdZddlmZddlZddlmZddlmZmZddl m Z GdddZ Gd d d ej Z ed krtejd d dS)zTest hyperparser, coverage 98%.) HyperParserN)requires)TkText) EditorWindowc@s eZdZddZejZejZdS) DummyEditwincCs"||_d|_d|_d|_d|_dS)Nz>>>)2ii)textZ indentwidthZtabwidthprompt_last_lineZnum_context_lines)selfr r G/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_hyperparser.py__init__ s zDummyEditwin.__init__N)__name__ __module__ __qualname__rrZ_build_char_in_string_funcZis_char_in_stringr r r rr src@sxeZdZdZeddZeddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZdS)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é"cCs6tdt|_|jt|j|_t|j|_dS)NZgui)rrrootZwithdrawrr reditwin)clsr r r setUpClass%s   zHyperParserTest.setUpClasscCs|`|`|j|`dS)N)r rrZdestroy)rr r r tearDownClass-s zHyperParserTest.tearDownClasscCs|jd|jdS)Ninsert)r rcode)r r r rsetUp3szHyperParserTest.setUpcCs|jddd|j_dS)Nz1.0endz>>>)r deleterr )r r r rtearDown6szHyperParserTest.tearDowncCs t|j|S)z> Return a parser object with index at 'index' )rr)r indexr r r get_parser:szHyperParserTest.get_parserc Cs|t }|jddd|d}WdQRX|dt|jd|j_ |d}| |j |j dd|j d|j ddd |d }dS) z6 test corner cases in the init method Zconsolez1.0z1.endz1.5NZprecedesrz54.5) assertRaises ValueErrorr Ztag_addr assertInstr exceptionrr assertEqualZrawtextgetr)r vepr r r test_init@s  zHyperParserTest.test_initcCs|j}|d}|||d}|||d}|||d}|||d}|||d}|||d}||dS)Nz1.0z1.4z2.3z3.3z3.7z4.6z12.54)r assertFalseZ is_in_string assertTrue)r r)r+r r rtest_is_in_stringTsz!HyperParserTest.test_is_in_stringcCs|j}|d}|||d}|||d}|||d}|||d}|||d}||dS)Nz1.0z1.1z2.5z3.4z3.6z4.14)r r.Z is_in_coder-)r r)r+r r rtest_is_in_codefszHyperParserTest.test_is_in_codecCs|j}dd}dd}|d}|||||||d}|||d||||||d}|||d ||||||d }|||d ||||d }||||||dS) NcSs |jddS)NF) mustclose)get_surrounding_brackets)parserr r rwithout_mustcloseyszGHyperParserTest.test_get_surrounding_bracket..without_mustclosecSs |jddS)NT)r1)r2)r3r r rwith_mustclose~szDHyperParserTest.test_get_surrounding_bracket..with_mustclosez3.2z5.6)z5.4z5.25z5.23)z5.21z5.24z6.15)z6.4z6.endz9.end)r Z assertIsNoneZassertTupleEqual)r r)r4r5r+r r rtest_get_surrounding_bracketvs$z,HyperParserTest.test_get_surrounding_bracketc Cs|j}|d}||d|d}|t}|WdQRX|dt|j|d}||d|d}||d|d }||d |d }||d|d }||d |d}||d|d}|t}|WdQRX|dt|j|d}||d |d}||d |d}||d |d}||d |d}||d|d}||ddS)Nz4.2zy z4.7zis inside a codez5.25z range(10)z6.7pyz6.8r!z7.9z8.endz x.__len__z9.13zr'asdf'z9.17z10.0z10.6z10.11z11.3z11.11Falsez12.6ucliché)r r(Zget_expressionr#r$r%r&r')r r)r+r*r r rtest_get_expressionsF  z#HyperParserTest.test_get_expressioncCsdd}||d||d||d||d||d||d||d ||d ||d ||d ||d ||d||d||d||d||d||d|tdddtd|tdddtd|tdddtd||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_identifierlenformat Exception) candidateresultZerr_msgr r r is_valid_ids  z8HyperParserTest.test_eat_identifier..is_valid_idZ2notidZvalid_idZ _valid_idZ valid_id_Z _2valid_idTruer8NoneforimportreturnZclicheuclichéua٢Z2au٢aua²z+ varrvarz+varr"z.var+ :?^\"z "a string")r-r.r(rr:r;)r r@r r rtest_eat_identifiers: z#HyperParserTest.test_eat_identifiercCs*tj}xtddD] }||d|d||||d|d||||dd|dd||||dd|dd||||dd|dd||||d|ddd||||d|d|d||dd|dd|d||dd|dd|dqWdS)Naré2rH)rr:ranger()r Zeat_idlengthr r r#test_eat_identifier_various_lengthss     z3HyperParserTest.test_eat_identifier_various_lengthsN)rrrr classmethodrrrrr r,r/r0r6r9rOrWr r r rrs  !49r__main__) verbosity)__doc__Zidlelib.hyperparserrZunittestZ test.supportrZtkinterrrZidlelib.editorrrZTestCaserrmainr r r rs