3 ี์2ax#ใ@stddlmZddlZddlmZddlmZmZddlm Z Gdd„dƒZ Gdd „d ej ƒZ e d krpejd d dS) ้)ฺ HyperParserN)ฺrequires)ฺTkฺText)ฺ EditorWindowc@s eZdZdd„ZejZejZdS)ฺ DummyEditwincCs"||_d|_d|_d|_d|_dS)N้T้2้๔้่)r r r )ฺtextZ indentwidthZtabwidthฺcontext_use_ps1Znum_context_lines)ฺselfr ฉr๚5/opt/alt/python36/lib64/python3.6/test_hyperparser.pyฺ__init__ s zDummyEditwin.__init__N)ฺ__name__ฺ __module__ฺ __qualname__rrZ_build_char_in_string_funcZis_char_in_stringrrrrr src@sxeZdZdZedd„ƒZedd„ƒZdd„Zdd „Zd d „Z d d „Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„ZdS)ฺ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รฉ"cCs6tdƒtƒ|_|jjƒt|jƒ|_t|jƒ|_dS)NZgui)rrฺrootZwithdrawrr rฺeditwin)ฺclsrrrฺ setUpClass%s   zHyperParserTest.setUpClasscCs|`|`|jjƒ|`dS)N)r rrZdestroy)rrrrฺ tearDownClass-s zHyperParserTest.tearDownClasscCs|jjd|jƒdS)Nฺinsert)r rฺcode)rrrrฺsetUp3szHyperParserTest.setUpcCs|jjddƒd|j_dS)Nz1.0ฺendT)r ฺdeleterr )rrrrฺtearDown6szHyperParserTest.tearDowncCs t|j|ƒS)N)rr)rฺindexrrrฺ get_parser:szHyperParserTest.get_parserc Cs–|jtƒ }|jjdddƒ|jdƒ}WdQRX|jdt|jƒƒd|j_ |jdƒ}|j |j |jj ddƒƒ|jj d|jj ddƒdƒ|jd ƒ}dS) NZconsolez1.0z1.endz1.5ฺprecedesFr้z54.5)ฺ assertRaisesฺ ValueErrorr Ztag_addr"ฺassertInฺstrฺ exceptionrr ฺ assertEqualZrawtextฺgetr)rฺveฺprrrฺ test_init@s  zHyperParserTest.test_initcCsค|j}|dƒ}|j|jƒƒ|dƒ}|j|jƒƒ|dƒ}|j|jƒƒ|dƒ}|j|jƒƒ|dƒ}|j|jƒƒ|dƒ}|j|jƒƒ|dƒ}|j|jƒƒdS)Nz1.0z1.4z2.3z3.3z3.7z4.6z12.54)r"ฺ assertFalseZ is_in_stringฺ assertTrue)rr+r-rrrฺtest_is_in_stringTsz!HyperParserTest.test_is_in_stringcCsŽ|j}|dƒ}|j|jƒƒ|dƒ}|j|jƒƒ|dƒ}|j|jƒƒ|dƒ}|j|jƒƒ|dƒ}|j|jƒƒ|dƒ}|j|jƒƒdS)Nz1.0z1.1z2.5z3.4z3.6z4.14)r"r0Z is_in_coder/)rr+r-rrrฺtest_is_in_codefszHyperParserTest.test_is_in_codecCsเ|j}dd„}dd„}|dƒ}|j||ƒƒ|j||ƒƒ|dƒ}|j||ƒdƒ|j||ƒ||ƒƒ|d ƒ}|j||ƒdƒ|j||ƒ||ƒƒ|d ƒ}|j||ƒdƒ|j||ƒƒ|dƒ}|j||ƒƒ|j||ƒƒdS)NcSs |jddS)NF)ฺ mustclose)ฺget_surrounding_brackets)ฺparserrrrฺwithout_mustcloseyszGHyperParserTest.test_get_surrounding_bracket..without_mustclosecSs |jddS)NT)r3)r4)r5rrrฺwith_mustclose~szDHyperParserTest.test_get_surrounding_bracket..with_mustclosez3.2z5.6๚5.4๚5.25z5.23๚5.21๚5.24z6.15๚6.4๚6.endz9.end)r8r9)r:r;)r<r=)r"Z assertIsNoneZassertTupleEqual)rr+r6r7r-rrrฺtest_get_surrounding_bracketvs$z,HyperParserTest.test_get_surrounding_bracketcCsฒ|j}|dƒ}|j|jƒdƒ|dƒ}|jtƒ}|jƒWdQRX|jdt|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ƒ}|jtƒ}|jƒWdQRX|jdt|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ƒdS)Nz4.2zy z4.7zis inside a codez5.25z range(10)z6.7ฺpyz6.8ฺz7.9z8.endz x.__len__z9.13zr'asdf'z9.17z10.0z10.6z10.11z11.3z11.11ฺFalsez12.6uclichรฉ)r"r*Zget_expressionr%r&r'r(r))rr+r-r,rrrฺtest_get_expression—sF  z#HyperParserTest.test_get_expressioncCsธdd„}|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ƒƒ|jtjdddƒtdƒƒ|jtjdddƒtdƒƒ|jtjdddƒtdƒƒ|j|dƒƒ|j|dƒƒ|j|dƒƒ|j|dƒƒ|j|dƒƒ|j|d ƒƒ|j|d!ƒƒ|j|d"ƒƒdS)#NcSsJtj|dt|ƒƒ}|t|ƒkr"dS|dkr.dSdj|t|ƒƒ}t|ƒ‚dS)NrTFz'Unexpected result: {} (expected 0 or {})rฺ_eat_identifierฺlenฺformatฺ Exception)ฺ candidateฺresultZerr_msgrrrฺ is_valid_idฬs  z8HyperParserTest.test_eat_identifier..is_valid_idZ2notidZvalid_idZ _valid_idZ valid_id_Z _2valid_idฺTruerAฺNoneฺforฺimportฺreturnZclicheuclichรฉuaูขZ2auูขauaยฒz+ varrฺ้varz+varr$z.var๚+๚ ๚:๚?๚^๚\๚"z "a string")r/r0r*rrCrD)rrIrrrฺtest_eat_identifierหs: z#HyperParserTest.test_eat_identifiercCs*tj}xtddƒD] }|j|d|d|ƒ|ƒ|j|d|d|ƒ|ƒ|j|dd|dd|ƒ|ƒ|j|dd|dd|ƒ|ƒ|j|dd|dd|ƒ|ƒ|j|d|ddd|ƒ|ƒ|j|d|d|ƒdƒ|j|dd|dd|ƒdƒ|j|dd|dd|ƒdƒqWdS)Nฺ้้ar๕รฉฺ2rQ)rrCฺranger*)rZeat_idZlengthrrrฺ#test_eat_identifier_various_lengthss     z3HyperParserTest.test_eat_identifier_various_lengthsN)rrrrฺ classmethodrrrr r"r.r1r2r>rBrXr_rrrrrs  !49rฺ__main__้)ฺ verbosity)Zidlelib.hyperparserrZunittestZ test.supportrZtkinterrrZidlelib.editorrrZTestCaserrฺmainrrrrฺs