a  zez#@stddlmZddlZddlmZddlmZmZddlm Z GdddZ Gdd d ej Z e d krpejd d dS) ) HyperParserN)requires)TkText) EditorWindowc@s eZdZddZejZejZdS) DummyEditwincCs"||_d|_d|_d|_d|_dS)N>>>)2ii)textZ indentwidthZtabwidthprompt_last_lineZnum_context_lines)selfr rV/opt/bitninja-python-dojo/embedded/lib/python3.9/idlelib/idle_test/test_hyperparser.py__init__ s zDummyEditwin.__init__N)__name__ __module__ __qualname__rrZ_build_char_in_string_funcZis_char_in_stringrrrrr 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 reditwinclsrrr setUpClass%s   zHyperParserTest.setUpClasscCs|`|`|j|`dSN)r rrZdestroyrrrr tearDownClass-s zHyperParserTest.tearDownClasscCs|jd|jdS)Ninsert)r rcoder rrrsetUp3szHyperParserTest.setUpcCs|jddd|j_dS)N1.0endr )r deleterr rrrrtearDown6szHyperParserTest.tearDowncCs t|j|Sr)rr)r indexrrr get_parser:szHyperParserTest.get_parsercCs|t*}|jddd|d}Wdn1s:0Y|dt|jd|j_ |d}| |j |j dd|j d|j ddd|d }dS) NZconsoler z1.endz1.5precedesr!z54.5) assertRaises ValueErrorr Ztag_addr%assertInstr exceptionrr assertEqualZrawtextgetr)r veprrr test_init@s ( zHyperParserTest.test_initcCs|j}|d}|||d}|||d}|||d}|||d}|||d}|||d}||dS)Nr z1.4z2.3z3.3z3.7z4.6z12.54)r% assertFalseZ is_in_string assertTruer r/r1rrrtest_is_in_stringTsz!HyperParserTest.test_is_in_stringcCs|j}|d}|||d}|||d}|||d}|||d}|||d}||dS)Nr z1.1z2.5z3.4z3.6z4.14)r%r4Z is_in_coder3r5rrrtest_is_in_codefszHyperParserTest.test_is_in_codecCs|j}dd}dd}|d}|||||||d}|||d||||||d}|||d ||||||d }|||d ||||d }||||||dS) NcSs |jddS)NFZ mustcloseZget_surrounding_bracketsparserrrrwithout_mustcloseyszGHyperParserTest.test_get_surrounding_bracket..without_mustclosecSs |jddS)NTr8r9r:rrrwith_mustclose~szDHyperParserTest.test_get_surrounding_bracket..with_mustclosez3.2z5.6)z5.45.25z5.23)z5.21z5.24z6.15)z6.4z6.endz9.end)r%Z assertIsNoneZassertTupleEqual)r r/r<r=r1rrrtest_get_surrounding_bracketvs$z,HyperParserTest.test_get_surrounding_bracketcCs|j}|d}||d|d}|t}|Wdn1sN0Y|dt|j|d}||d|d}||d|d }||d |d }||d|d }||d |d}||d|d}|t}|Wdn1s,0Y|dt|j|d}||d |d}||d |d}||d |d}||d |d}||d|d}||ddS)Nz4.2zy z4.7zis inside a coder>z range(10)z6.7pyz6.8r'z7.9z8.endz x.__len__z9.13zr'asdf'z9.17z10.0z10.6z10.11z11.3z11.11Falsez12.6cliché)r%r.Zget_expressionr)r*r+r,r-)r r/r1r0rrrtest_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) candidateresulterr_msgrrr is_valid_ids z8HyperParserTest.test_eat_identifier..is_valid_idZ2notidZvalid_idZ _valid_idZ valid_id_Z _2valid_idTruerANoneforimportreturnZclicherBua٢Z2au٢aua²z+ varrvarz+varr(z.var+ :?^\"z "a string")r3r4r.rrDrE)r rKrrrtest_eat_identifiers: z#HyperParserTest.test_eat_identifiercCs$tj}tddD] }||d|d||||d|d||||dd|dd||||dd|dd||||dd|dd||||d|ddd||||d|d|d||dd|dd|d||dd|dd|dqdS)Naré2rS)rrDranger.)r Zeat_idlengthrrr#test_eat_identifier_various_lengthss     z3HyperParserTest.test_eat_identifier_various_lengthsN)rrrr classmethodrrrr#r%r2r6r7r?rCrZrbrrrrrs   !49r__main__) verbosity)Zidlelib.hyperparserrZunittestZ test.supportrtkinterrrZidlelib.editorrrZTestCaserrmainrrrrs