a zeT@sJddlmZddlZddlZddlZddlZddlmZddlZGdddZ GdddZ dd Z d d Z gd e _ d dZgde_ ddZgde_ ddZgde_ ddZgde_ ddZgde_ ddZgde_ ddZd d!Zgd"e_ d#d$Zd%d&Zgd'e_ d(d)Zd*d+Zd,ge_ d-d.Zd/d0Zgd1e_ d2d3Zgd4e_ d5d6Zgd7e_ d8d9Zgd:e_ d;d<Zd=d>Z gd?d@dAgdBd@dCge _ GdDdEdEZ!GdFdGdGej"Z#GdHdIdIe#Z$ej%GdJdKdKe#Z&GdLdMdMej"Z'GdNdOdOZ(dPdQZ)dRdSZ*GdTdUdUej"Z+e,dVkrFe-dS)W)supportNwrapsc@s(eZdZdZddZddZddZdS) tracecontextz/Context manager that traces its enter and exit.cCs||_||_dSNoutputvalueselfrr r J/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_sys_settrace.py__init__sztracecontext.__init__cCs|j|jdSrrappendr r r r r __enter__sztracecontext.__enter__cGs|j|j dSrrr exc_infor r r __exit__sztracecontext.__exit__N)__name__ __module__ __qualname____doc__rrrr r r r r src@s(eZdZdZddZddZddZdS) asynctracecontextz>Asynchronous context manager that traces its aenter and aexit.cCs||_||_dSrrr r r r rszasynctracecontext.__init__cs|j|jdSrrrr r r __aenter__szasynctracecontext.__aenter__cs|j|j dSrrrr r r __aexit__!szasynctracecontext.__aexit__N)rrrrrrrr r r r rsrcCs|D] }|VqdS)z0Convert an iterable to an asynchronous iterator.Nr )iterablexr r r asynciter$srcCsdSNr r r r r basic+sr")rcallr!liner!returncCsd}~d}dSr r rr r r arigo_example0;sr*)r#r%r&r&r.r(cCsd}~d}dSr r r)r r r arigo_example1Hsr0cCsd}~d}dSr r r)r r r arigo_example2Usr1)r#r%r+r&r&r5r(cCsd}~d}dSr r r)r r r one_instr_linegsr7)r#r%r+r&r9r(cCs$d}tdD]}|rd}q d}q dSNr!r,range)rar r r no_pop_topsrs  r?) r#r%r+r8r&r+r8r2r+)r,r(cCsd}|stqd}dSr )Zbla)yrr r r no_pop_blockssrC)r#r%r+r2r3r(cCsd}dSr r r)r r r calledsrEcCs tdSr)rEr r r r r$sr$)r#r%r$r&rIr(r'cCstdSr Exceptionr r r r raisessrMcCs"z tWntyYn0dSr)rMrLr r r r test_raises  rN) r#r%r+rFrHrI exceptionrJr,rPr8r2rDcCst||tj_dSr)syssettrace _getframef_backf_traceZ tracefuncr r r _settrace_and_returns rXcCs t|dSr)rXrWr r r settrace_and_returnsrYr'cCst||tj_tdSr)rRrSrTrUrV RuntimeErrorrWr r r _settrace_and_raises  r[cCs$z t|WntyYn0dSr)r[rZrWr r r settrace_and_raises  r\)rQr8r2rDcCsd}d}||kr|d}ndS)Nr.r!r )r>br r r ireturn_examples  r^)r#r%r+r8r2r@rAr(cCs<tdd}zd}||}|d7}qWnty6Yn0dS)Nrr9r!r= IndexError)itemsir]r r r tightloop_examples   rd) r#r%r+r8r-r-r-r-)r.rPr@r4r6cCs4tdd}zd}||}qWnty.Yn0dS)Nr!r3rr`)rbrcr r r tighterloop_examples   re) r#r%r+r8r2r2r2r2)r3rPr-r@r_ccsz dVWn0dS)NTr r r r r generator_functionsrfcCs tt}tdD]}|}qdS)N )anyrfr=)rrBr r r generator_examples  ri) r#r+ir$r&r&rnr()rnr$rnrP)r&)rqr(r-r@rgr/c@s.eZdZd ddZddZddZdd ZdS) TracerNcCs||_||_g|_dSr)trace_line_eventstrace_opcode_eventsevents)r rsrtr r r r+szTracer.__init__cCs(|jdur|j|_|jdur$|j|_dSr)rs f_trace_linesrtf_trace_opcodes)r framer r r _reconfigure_frame0s  zTracer._reconfigure_framecCs"|||j|j|f|jSrryrurf_linenotracer rxeventargr r r r|6s z Tracer.tracecCs0||dddD|j|j|f|jS)Ncss|] }|VqdSrr ).0or r r =z)Tracer.traceWithGenexp..r!rzr}r r r traceWithGenexp;s zTracer.traceWithGenexp)NN)rrrrryr|rr r r r rr*s rrc@seZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAS)B TraceTestCasecCs(t|_t|tjtdSr)gc isenabledusing_gcdisable addCleanuprRrSgettracerr r r setUpFs zTraceTestCase.setUpcCs|jrtdSr)rrenablerr r r tearDownKszTraceTestCase.tearDowncCstS)z@Helper to allow test subclasses to configure tracers differentlyrrr r r r make_tracerOszTraceTestCase.make_tracerc sNfdd|D}||krJ|ddtdd|Ddd|DdS)Ncsg|]\}}||fqSr r )rle line_offsetr r Urz0TraceTestCase.compare_events..z"events did not match expectation:  cSsg|] }t|qSr strrrr r r rYrcSsg|] }t|qSr rrr r r rZr)failjoindifflibZndiff)r rruexpected_eventsr rr compare_eventsTs zTraceTestCase.compare_eventscCs<|}t|j|td||jj|j|dSr)rrRrSr|r__code__co_firstlinenoru)r funcrutracerr r r run_and_compare\s   zTraceTestCase.run_and_comparecCs|||jdSr)rrur rr r r run_testdszTraceTestCase.run_testcCs6|}||jtd||jj|j|jdSr)rr|rRrSrrrru)r rrr r r run_test2gs    zTraceTestCase.run_test2cCstdtdusJdSrrRrSrrr r r test_set_and_retrieve_nonens z(TraceTestCase.test_set_and_retrieve_nonec CsBdd}t|zt|us$JWtdn td0dS)NcWsdSrr )argsr r r fnssz4TraceTestCase.test_set_and_retrieve_func..fnr)r rr r r test_set_and_retrieve_funcrs  z(TraceTestCase.test_set_and_retrieve_funccCs|tdSr)rr"rr r r test_01_basic|szTraceTestCase.test_01_basiccCs|tdSr)rr*rr r r test_02_arigo0~szTraceTestCase.test_02_arigo0cCs|tdSr)rr0rr r r test_02_arigo1szTraceTestCase.test_02_arigo1cCs|tdSr)rr1rr r r test_02_arigo2szTraceTestCase.test_02_arigo2cCs|tdSr)rr7rr r r test_03_one_instrszTraceTestCase.test_03_one_instrcCs|tdSr)rrCrr r r test_04_no_pop_blockssz#TraceTestCase.test_04_no_pop_blockscCs|tdSr)rr?rr r r test_05_no_pop_topssz!TraceTestCase.test_05_no_pop_topscCs|tdSr)rr$rr r r test_06_callszTraceTestCase.test_06_callcCs|tdSr)rrNrr r r test_07_raiseszTraceTestCase.test_07_raisecCs|tdSr)rrYrr r r test_08_settrace_and_returnsz)TraceTestCase.test_08_settrace_and_returncCs|tdSr)rr\rr r r test_09_settrace_and_raisesz(TraceTestCase.test_09_settrace_and_raisecCs|tdSr)rr^rr r r test_10_ireturnszTraceTestCase.test_10_ireturncCs|tdSr)rrdrr r r test_11_tightloopszTraceTestCase.test_11_tightloopcCs|tdSr)rrerr r r test_12_tighterloopsz!TraceTestCase.test_12_tighterloopcCsH|t|}t|jttd|tjj|j tj dSr) rrirrRrSrrrrru)r rr r r test_13_genexps    zTraceTestCase.test_13_genexpcCsdd}||gddS)NcSsd}dS)NFrr r)r r r onlinerssz2TraceTestCase.test_14_onliner_if..onliners)r#r%r8r:r)r rr r r test_14_onliner_ifs z TraceTestCase.test_14_onliner_ifcCs4dd}||gddd}||gddS)NcSstdD]}qdSNr,r<r)r r r for_examples z0TraceTestCase.test_15_loops..for_example)r#r%r+r%r+r%r'cSsd}|dkr|d8}qdS)Nr,rr!r r)r r r while_examplesz2TraceTestCase.test_15_loops..while_example)r#r+r8r2r8r2r8r:r)r rrr r r test_15_loopss zTraceTestCase.test_15_loopscCs&i}td|||dgddS)Nadef f(): passf)r#)r&)rr()execr)r namespacer r r test_16_blank_liness  z!TraceTestCase.test_16_blank_linescCsdd}||ddgdS)NcSsdt_d}dSr)rRrTrV)linenor r r rs z0TraceTestCase.test_17_none_f_trace..funcr#r%rrr r r test_17_none_f_traces z"TraceTestCase.test_17_none_f_tracecCsdd}||gddS)Nc SsTz.func) r#r%r+r8r9rPr2r-)r&) r&)rr(rrr r r test_18_except_with_names z&TraceTestCase.test_18_except_with_namecCsdd}||gddS)NcSs4zz tWd}nd}0Wnty.d}Yn0dS)NrrK)rBr]r r r rs  z7TraceTestCase.test_19_except_with_finally..func) r#r%r+r8rr-r@r4r6rrr r r test_19_except_with_finallys z)TraceTestCase.test_19_except_with_finallycspGdddfddfdd}|}gd}z||jWntyVYn0|jj|j|dS)Nc@s$eZdZddZddZddZdS)zBTraceTestCase.test_20_async_for_loop..AsyncIteratorWrappercSst||_dSr)iter_it)r objr r r rszKTraceTestCase.test_20_async_for_loop..AsyncIteratorWrapper.__init__cSs|Srr rr r r __aiter__szLTraceTestCase.test_20_async_for_loop..AsyncIteratorWrapper.__aiter__cs(z t|jWSty"tYn0dSr)nextr StopIterationStopAsyncIterationrr r r __anext__s  zLTraceTestCase.test_20_async_for_loop..AsyncIteratorWrapper.__anext__N)rrrrrrr r r r AsyncIteratorWrappersrcs$d2z3dHW}|}q6d}dS)Nabc*r )ZletterrrB)rr r doit_asyncsz8TraceTestCase.test_20_async_for_loop..doit_asyncc s:}z"t||dWtdn td0dSrrRrSsendrr)rr r run$s   z1TraceTestCase.test_20_async_for_loop..run)(r#r%)ir$)r&)rr()ir$)r&)rr(rjrkrmror!rPr+r%rjrkrmrorr+r%rjrkrmrorr+r%rjrkrmrp)rGr&rHrOrJrr8r:rr|rLrrrrur rrrur )rrr test_20_async_for_loops  )  z$TraceTestCase.test_20_async_for_loopcsjddfddfdd}|}gd}z||jWntyPYn0|jj|j|dS)NcSs dVdS)NrIr r r r r async_gen_sz7TraceTestCase.test_21_async_for_else..async_gencs&da2z3dHW}daq 6dadSNr,r3rA)r>rc)rr r async_testbsz8TraceTestCase.test_21_async_for_else..async_testc s:}z"t||dWtdn td0dSrrr)rr r rjs   z1TraceTestCase.test_21_async_for_else..run)r#r+r8rFrHrJrr2r8)rIr$rJrr@r_rrr )rrr test_21_async_for_else]s    z$TraceTestCase.test_21_async_for_elseN)$rrrrr staticmethodrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r rBsB      Lrcs,eZdZdZfddZeddZZS)SkipLineEventsTraceTestCasez8Repeat the trace tests, but with per-line events skippedcs"dd|D}t|||dS)NcSsg|]}|ddkr|qSr%r rrr r r rrz>SkipLineEventsTraceTestCase.compare_events..)superr)r rrurZskip_line_events __class__r r rsz*SkipLineEventsTraceTestCase.compare_eventscCs tddS)NF)rsrr r r r rsz'SkipLineEventsTraceTestCase.make_tracerrrrrrrr __classcell__r r rr rs rcs,eZdZdZfddZeddZZS)TraceOpcodesTestCasez;Repeat the trace tests, but with per-opcodes events enabledcsFdd|D}t|dkr2|jt|t|ddt|||dS)NcSsg|]}|ddkr|qS)r!Zopcoder rr r r rrz7TraceOpcodesTestCase.compare_events..r!z)No 'opcode' events received by the tracer)msg)lenZ assertLessrr)r rrurZskip_opcode_eventsrr r rs  z#TraceOpcodesTestCase.compare_eventscCs tddS)NT)rtrr r r r rsz TraceOpcodesTestCase.make_tracerrr r rr rs rc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)RaisingTraceFuncTestCasecCs|tjtdSrrrRrSrrr r r rszRaisingTraceFuncTestCase.setUpcCs||jkrtn|jSdS)zXA trace function that raises an exception in response to a specific trace event.N) raiseOnEvent ValueErrorr|r}r r r r|s zRaisingTraceFuncTestCase.tracecCs |jdkrd}d|}ndSdS)zThe function to trace; raises an exception if that's the case we're testing, so that the 'exception' trace event fires.rPrr!N)r)r rrBr r r rs  zRaisingTraceFuncTestCase.fc Csx||_zPttdD]:}t|jz |WntyFYq0|dqWnt yr|dYn0dS)zTTests that an exception raised in response to the given event is handled OK.r!zexception not raised!zrecursion counter not resetN) rr=rRgetrecursionlimitrSr|rrrrZ)r r~rcr r r run_test_for_events    z+RaisingTraceFuncTestCase.run_test_for_eventcCs|ddS)Nr$rrr r r test_callsz"RaisingTraceFuncTestCase.test_callcCs|ddS)Nr&rrr r r test_linesz"RaisingTraceFuncTestCase.test_linecCs|ddS)Nr(rrr r r test_returnsz$RaisingTraceFuncTestCase.test_returncCs|ddSNrPrrr r r test_exceptionsz'RaisingTraceFuncTestCase.test_exceptioncs\ddfddtz Wn"tyLddl}|Yn 0|ddS)NcSstdD] }t|qdS)Nr.)r=printrr r r rs z4RaisingTraceFuncTestCase.test_trash_stack..fcs&|dkr"|jjjdkr"tdS)Nr&r,z i am crashing)r{rrrZ)rxwhyextrargr r rs z4RaisingTraceFuncTestCase.test_trash_stack..grzexception not propagated)rRrSrZrZcollectr)r rr rr test_trash_stacks   z)RaisingTraceFuncTestCase.test_trash_stackc sfdd}fddt}z6tz |WntyFYn0Wt|n t|0dS)NcSsd}|jdS)Nr)Z no_such_attrr)r r r rsz.fcs"|dkr|\}}}|tSr)ZassertIsInstancerL)rxr~rtyperPr|rr r r rs  z.g)rRrrSAttributeError)r rZexistingr r r test_exception_argumentss   z1RaisingTraceFuncTestCase.test_exception_argumentsN) rrrrr|rrrrrrrr r r r r rs rc@s"eZdZdZd ddZddZdS) JumpTracerz>Defines a trace function that jumps from one place to another.r&FcCs6|j|_||_||_||_|r"dn|jj|_d|_dS)NF)rcodejumpFromjumpTor~r firstLinedone)r functionrrr~ decoratedr r r r s zJumpTracer.__init__cCs|jr dS|jdur4|j|jkr4|dkr4|jd|_||jkr|jr|j|j|jkr|}|durv|j|jkrv|j}qZ|durz|j|j|_Wnt y|j|_Yn0d|_|j S)Nr&r!T) rrf_coderr{r~rrUr TypeErrorr|)r rxr~rrr r r r|s&  zJumpTracer.traceN)r&F)rrrrrr|r r r r r s  r c CsJz|dWn6tyD}z|dt|vWYd}~n d}~00dS)Nr,Zinteger)rrrrrr r r no_jump_to_non_integers,src CsVztj}|j|_Wn2tyH}zdt|vr4WYd}~nd}~00tddS)Nr|z'Trace-function-less jump failed to fail)rRrTrUr{rrAssertionError)Zprevious_framerr r r no_jump_without_trace_function4s   rc@s:eZdZddZddZddd Zdd d Zdd d ZdddZedddgddZ eddgdddZ eddddgddZ eddgdddZ eddddgd d!Z eddgd"d#d$Zedddgd%d&Zeddgd'd(d)Zedd*dd*gd+d,Zedd-dd-ged.fd/d0Zedd1dd1ged.fd2d3Zedd1ddged4fd5d6Zedddged4fd7d8Zeddddgd9d:Zeddgd;dd?Zeddddgd@dAZeddgdBdCdDZeddgdBdEdFZedddgdGdHZeddgdIdJdKZedddgdLdMZ eddgdNdOdPZ!edd-gdQdRdSZ"eddgdTdUdVZ#eddgdWdXdYZ$eddgdWdZd[Z%eddgd\d]d^Z&eddgd\d_d`Z'eddgdadbdcZ(eddgdadddeZ)eddgdfdgdhZ*eddgdfdidjZ+edkd1gdldmdnZ,eddgdodpdqZ-eddgdodrdsZ.eddgdtdudvZ/eddkgdwdxdyZ0edd-d-dkgdzd{Z1edd-d-dkgd|d}Z2edddged~fddZ3edddgedfddZ4edddgedfddZ5edddgedfddZ6edddgedfddZ7edddgedfddZ8eddgedfddZ9eddgedfddZ:eddddgedfddZ;eddddgedfddZeddgdedfddZ?eddgdedfddZ@eddgedfddZAeddddgedfddZBeddgedfddZCedddgedfddZDedd-dgedfddZEedddgddZFeddgdddZGeddgdddZHeddgedfddZIeddgedfddZJeddgdedfddZKedddgedfddZLed-dgdedfddZMed-dgdedfddZNeddgd¢ddĄZOeddgd¢ddƄZPedd-ddged4fddȄZQed-dddgedfddʄZRed-dddgedfdd̄ZSdd΄ZTddЄZUdd҄ZVddԄZWedddgdedfd׍ddلZXedddgdedfd׍dd݄ZYedddgdedfd׍ddZZeddddgddddZ[dS) JumpTestCasecCs |tjttddSrrrr r r rCszJumpTestCase.setUpcCs.||kr*|dt|ddt|dS)NzOutputs don't match: Expected: rz Received: )rrepr)r expectedZreceivedr r r compare_jump_outputGsz JumpTestCase.compare_jump_outputNr&Fc Cs~t|||||}t|jg} |dur2|| n2|j||| Wdn1sZ0Ytd||| dSr)r rRrSr|assertRaisesRegexr r rrrrerrorr~rrrr r r rMs   & zJumpTestCase.run_testc Cst|||||}t|jg} |dur8t|| n8|j|t|| Wdn1sf0Ytdtd||| dSr) r rRrSr|asynciorrZset_event_loop_policyrr r r r run_async_testZs  ,  zJumpTestCase.run_async_testcsfdd}|S)zqDecorator that creates a test that makes a jump from one place to another in the following code. cs"tfdd}|S)Nc s|jdddSNT)r!r~r)rrr!r~rrrrr r testms z7JumpTestCase.jump_test..decorator..testrrr&r!r~rrrrr decoratorlsz)JumpTestCase.jump_test..decoratorr rrrr!r~r*r r(r jump_testhszJumpTestCase.jump_testcsfdd}|S)z~Decorator that creates a test that makes a jump from one place to another in the following asynchronous code. cs"tfdd}|S)Nc s|jdddSr$)r#rr%r r r&ys z=JumpTestCase.async_jump_test..decorator..testrr'r(r)r r*xsz/JumpTestCase.async_jump_test..decoratorr r+r r(r async_jump_testtszJumpTestCase.async_jump_testr!r9cCs"|d|d|ddSNr!r,r9rrr r r test_jump_simple_forwardss  z&JumpTestCase.test_jump_simple_forwardsr,)r!r!r,cCs|d|ddSr;r/r0r r r test_jump_simple_backwardss z'JumpTestCase.test_jump_simple_backwardsr.cCs6dD]"}|ddD]}|dqq|ddS)Nr!r,r,r9r3r.r/rrcjr r r test_jump_out_of_block_forwardss  z,JumpTestCase.test_jump_out_of_block_forwardsrA)r!r9r.r!r9r.rAr5cCsJ|ddD],}|ddD]}|dq |dq|ddS)Nr!rr9)r,r.rAr5r/r5r r r test_jump_out_of_block_backwardss    z-JumpTestCase.test_jump_out_of_block_backwardsr3csHdD]>}tddg2z 3dHW}|d|dq6|dqdS)Nrr!r,r9r3r.rrrrcr r r )test_jump_out_of_async_for_block_forwardss  z6JumpTestCase.test_jump_out_of_async_for_block_forwards)r,r3r,r3r.rAcsPdD]F}|dtdg2z 3dHW}|d|dq6|dqdS)Nrr,r!r3r.rArrr:r r r *test_jump_out_of_async_for_block_backwardss   z7JumpTestCase.test_jump_out_of_async_for_block_backwardscCs|d|ddS)Nr!r9r/r0r r r test_jump_to_codeless_lines z'JumpTestCase.test_jump_to_codeless_line)r!r,r9cCs"|d|d|ddSr.r/r0r r r test_jump_to_same_lines  z#JumpTestCase.test_jump_to_same_linercCszH|dW|dz|dW|dn |d0|dn<|dz|dW|dn |d0|d0dS)Nr,r3rArrr/r0r r r test_jump_in_nested_finallys     z(JumpTestCase.test_jump_in_nested_finallyr5c CsRz,|dddW|d|ddS|d|d0|ddS)Nr,r!rrAr5rr/r0r r r test_jump_in_nested_finally_2s     z*JumpTestCase.test_jump_in_nested_finally_2 cCsz|dddW|dz|dW|dn |d0|ddSz|dW|dn |d0|dn<|dz|dW|dn |d0|d0|ddS) Nr,r!rrArrgrC r/r0r r r test_jump_in_nested_finally_3s*        z*JumpTestCase.test_jump_in_nested_finally_3Z unreachablec CszL|dW|d|ddSz|dW|dq|d0nH|d|dYdSz|dW|dn |d00|ddS)Nr,r3r.rrgrDr/r0r r r 5test_no_jump_over_return_try_finally_in_finally_blocks"        zBJumpTestCase.test_no_jump_over_return_try_finally_in_finally_blockcCs$|d|dq |ddS)Nr!r9r3r/r0r r r test_no_jump_infinite_while_loops  z-JumpTestCase.test_no_jump_infinite_while_loopcCs.d}|d|dkr*|d|d7}qdS)Nr!r,r3r/r:r r r #test_jump_forwards_into_while_blocks   z0JumpTestCase.test_jump_forwards_into_while_block)r9r9r9r.cCs.d}|dkr |d|d7}q|ddS)Nr!r,r9r.r/r:r r r $test_jump_backwards_into_while_blocks   z1JumpTestCase.test_jump_backwards_into_while_blockcCsBt|d|dWdn1s*0Y|ddSr.rrr0r r r $test_jump_forwards_out_of_with_block s (z1JumpTestCase.test_jump_forwards_out_of_with_blockc sVt|d4IdH |dWdIdHqH1IdHs>0Y|ddSr.rrr0r r r *test_jump_forwards_out_of_async_with_blocks4z7JumpTestCase.test_jump_forwards_out_of_async_with_block)r!r,r!r,r9rIcCsB|dt|d|dWdn1s40YdSr.rrr0r r r %test_jump_backwards_out_of_with_blocks  z2JumpTestCase.test_jump_backwards_out_of_with_blockc sV|dt|d4IdH |dWdIdHqR1IdHsH0YdSr.rrr0r r r +test_jump_backwards_out_of_async_with_blocks z8JumpTestCase.test_jump_backwards_out_of_async_with_blockc Cs4z|dW|dn |d0|ddSNr,r3r.r/r0r r r +test_jump_forwards_out_of_try_finally_block!s z8JumpTestCase.test_jump_forwards_out_of_try_finally_block)r!r!r9r.c Cs4|dz|dW|dn |d0dSNr!r9r.r/r0r r r ,test_jump_backwards_out_of_try_finally_block)s  z9JumpTestCase.test_jump_backwards_out_of_try_finally_blockcCs6z|dWn|dYn0|ddSrr/r0r r r *test_jump_forwards_out_of_try_except_block1s  z7JumpTestCase.test_jump_forwards_out_of_try_except_block)r!r!r9cCs6|dz|dWn|dYn0dSrTr/r0r r r +test_jump_backwards_out_of_try_except_block:s   z8JumpTestCase.test_jump_backwards_out_of_try_except_block)r3r5rcCs\z ddWn@ty2|d|dYntyL|dYn0|ddSNr!rr3r.r5rZeroDivisionErrorrFloatingPointErrorr0r r r test_jump_between_except_blocksCs    z,JumpTestCase.test_jump_between_except_blocks)r3rAr5cCsFz ddWn*|d|d|dYn0|ddS)Nr!rr3r.rAr5r/r0r r r test_jump_within_except_blockNs   z*JumpTestCase.test_jump_within_except_block)r!r3r.rncCsv|dt|d|dWdn1s40Yt|d|dWdn1sh0YdSNr!r,r9r3r.rNr0r r r test_jump_across_withXs   ( z"JumpTestCase.test_jump_across_withc s|dt|d4IdH |dWdIdHqR1IdHsH0Yt|d4IdH |dWdIdHq1IdHs0YdSr^rPr0r r r test_jump_across_async_with`s  4z(JumpTestCase.test_jump_across_async_with)r!r9r.rAc Cs`|ddD]B}t|d|dWdn1s<0Y|dq|ddSNr!rr9r3r.rArNr:r r r ,test_jump_out_of_with_block_within_for_blockhs   ( z9JumpTestCase.test_jump_out_of_with_block_within_for_blockc st|ddD]V}t|d4IdH |dWdIdHqZ1IdHsP0Y|dq|ddSrarPr:r r r 2test_jump_out_of_async_with_block_within_for_blockqs  4 z?JumpTestCase.test_jump_out_of_async_with_block_within_for_block)r!r,r9r.rIrAc Cs|dt|dNt|d|dWdn1s@0Y|dWdn1sh0Y|ddSNr!r,r9r3r.rArNr0r r r -test_jump_out_of_with_block_within_with_blockzs    ((z:JumpTestCase.test_jump_out_of_with_block_within_with_blockc s|dt|dbt|d4IdH |dWdIdHq^1IdHsT0Y|dWdn1s|0Y|ddSrd)rrrr0r r r 3test_jump_out_of_async_with_block_within_with_blocks   4(z@JumpTestCase.test_jump_out_of_async_with_block_within_with_block)r,r3rAr5cCszL|dWt|d|dWdn1s80Y|dn@t|d|dWdn1sx0Y|d0|ddSNr,r3r.rAr5rNr0r r r 0test_jump_out_of_with_block_within_finally_blocks  ( ( z=JumpTestCase.test_jump_out_of_with_block_within_finally_blockcsz`|dWt|d4IdH |dWdIdHqV1IdHsL0Y|dnTt|d4IdH |dWdIdHq1IdHs0Y|d0|ddSrgrPr0r r r 6test_jump_out_of_async_with_block_within_finally_blocks 4 4 zCJumpTestCase.test_jump_out_of_async_with_block_within_finally_blockr)r!r9r.rCrDc Csz|ddD]\}|ddD]>}|dz"dD]}|dq4W|dq |d0q |dq|d dS) Nr!rr9r3r.rrgrCrDr/)rrcr6kr r r &test_jump_out_of_complex_nested_blockss    z3JumpTestCase.test_jump_out_of_complex_nested_blocks)r!r,r.cCsL|dt|d}|dWdn1s40Y|ddSNr!r,r3r.rNrrr r r test_jump_out_of_with_assignments   (z-JumpTestCase.test_jump_out_of_with_assignmentc s`|dt|d4IdH }|dWdIdHqR1IdHsH0Y|ddSrlrPrmr r r &test_jump_out_of_async_with_assignments  4z3JumpTestCase.test_jump_out_of_async_with_assignment)r!rArrc Cs\|dz6|d|s*W|ddS|dW|dn |d0|ddS)Nr!r9rrArr/r0r r r *test_jump_over_return_in_try_finally_blocks    z7JumpTestCase.test_jump_over_return_in_try_finally_block)r!r9rrgrC c Csr|d|dz4|d|s2W|dqd|dW|dn |d0|dqdq |ddS)Nr!r9r.rgrrCrqr/r0r r r )test_jump_over_break_in_try_finally_blocks      z6JumpTestCase.test_jump_over_break_in_try_finally_blockcCsF|d|s$dD]}|dqn|d|d|ddSNr!r4r3rAr5rr/r:r r r $test_jump_over_for_block_before_elses   z1JumpTestCase.test_jump_over_for_block_before_elsecsV|d|s4tdg2z3dHW}|dq6n|d|d|ddSNr!r9r3rAr5rr<r:r r r *test_jump_over_async_for_block_before_elses   z7JumpTestCase.test_jump_over_async_for_block_before_elseZaftercCs|d|ddSr;r/r0r r r test_no_jump_too_far_forwardss z*JumpTestCase.test_no_jump_too_far_forwardsrIbeforecCs|d|ddSr;r/r0r r r test_no_jump_too_far_backwardss z+JumpTestCase.test_no_jump_too_far_backwardsexceptcCs,z|dWn|dYn0dSNr,r3r/r0r r r test_no_jump_to_except_1s  z%JumpTestCase.test_no_jump_to_except_1cCs2z|dWnty,|dYn0dSr{rrr0r r r test_no_jump_to_except_2s   z%JumpTestCase.test_no_jump_to_except_2c CsFz|dWn2ty@}z|d|WYd}~n d}~00dSr{r}rr r r test_no_jump_to_except_3s  z%JumpTestCase.test_no_jump_to_except_3c CsJz|dWn6ttfyD}z|d|WYd}~n d}~00dSr{)rrrZrr r r test_no_jump_to_except_4s  z%JumpTestCase.test_no_jump_to_except_4ZintocCs"|ddD]}|dqdS)Nr!r3r9r/r:r r r $test_no_jump_forwards_into_for_blocks z1JumpTestCase.test_no_jump_forwards_into_for_blockcs4|dtddg2z3dHW}|dq6dSr.r<r:r r r *test_no_jump_forwards_into_async_for_block$s z7JumpTestCase.test_no_jump_forwards_into_async_for_blockcCs"dD]}|dq|ddS)Nr3r,r9r/r:r r r %test_no_jump_backwards_into_for_block*s z2JumpTestCase.test_no_jump_backwards_into_for_blockcs4tddg2z3dHW}|dq 6|ddSr.r9r:r r r +test_no_jump_backwards_into_async_for_block0sz8JumpTestCase.test_no_jump_backwards_into_async_for_blockcCsB|dt|d|dWdn1s40YdSr.rNr0r r r %test_no_jump_forwards_into_with_block6s  z2JumpTestCase.test_no_jump_forwards_into_with_blockc sV|dt|d4IdH |dWdIdHqR1IdHsH0YdSr.rPr0r r r +test_no_jump_forwards_into_async_with_block<s z8JumpTestCase.test_no_jump_forwards_into_async_with_block)r!r,rqcCsBt|d|dWdn1s*0Y|ddSr.rJr0r r r &test_no_jump_backwards_into_with_blockBs (z3JumpTestCase.test_no_jump_backwards_into_with_blockc sVt|d4IdH |dWdIdHqH1IdHs>0Y|ddSr.rLr0r r r ,test_no_jump_backwards_into_async_with_blockHs4z9JumpTestCase.test_no_jump_backwards_into_async_with_blockc Cs4|dz|dW|dn |d0dSrTr/r0r r r ,test_no_jump_forwards_into_try_finally_blockNs  z9JumpTestCase.test_no_jump_forwards_into_try_finally_blockc Cs4z|dW|dn |d0|ddSrRr/r0r r r -test_no_jump_backwards_into_try_finally_blockVs z:JumpTestCase.test_no_jump_backwards_into_try_finally_blockcCs6|dz|dWn|dYn0dSrTr/r0r r r +test_no_jump_forwards_into_try_except_block^s   z8JumpTestCase.test_no_jump_forwards_into_try_except_blockcCs6z|dWn|dYn0|ddSrr/r0r r r ,test_no_jump_backwards_into_try_except_blockgs  z9JumpTestCase.test_no_jump_backwards_into_try_except_blockc Csnz ddWnRty2|d|dYn.ty^}z|dWYd}~n d}~00|ddSrXrYrr r r $test_no_jump_between_except_blocks_2qs    z1JumpTestCase.test_no_jump_between_except_blocks_2c Cs4|dz|dW|dn |d0dSrTr/r0r r r test_jump_into_finally_block|s  z)JumpTestCase.test_jump_into_finally_block)r,rAr5c CsRz,|d|dW|d|dn|d|d0|ddS)Nr,r9r.rAr5r/r0r r r +test_jump_into_finally_block_from_try_blocks     z8JumpTestCase.test_jump_into_finally_block_from_try_block)r!r9r!r9r.c Cs4|dz|dW|dn |d0dSrTr/r0r r r test_jump_out_of_finally_blocks  z+JumpTestCase.test_jump_out_of_finally_blockzinto an 'except'cCs4|dz|dWn|dYn0dSrTr/r0r r r #test_no_jump_into_bare_except_blocks  z0JumpTestCase.test_no_jump_into_bare_except_blockcCs:|dz|dWnty4|dYn0dSrTrrLr0r r r (test_no_jump_into_qualified_except_blocks   z5JumpTestCase.test_no_jump_into_qualified_except_block)r,r.rAcCsJz|d|dWn"|d|dYn0|ddSNr,r9r.rArr/r0r r r 2test_no_jump_into_bare_except_block_from_try_blocks   z?JumpTestCase.test_no_jump_into_bare_except_block_from_try_blockcCsPz|d|dWn(ty@|d|dYn0|ddSr)rrZr0r r r 7test_no_jump_into_qualified_except_block_from_try_blocks    zDJumpTestCase.test_no_jump_into_qualified_except_block_from_try_block)r!r9rAzout of an 'except'cCsF|dz|dddWn |d|dYn0dSNr!r9rrAr5r/r0r r r %test_no_jump_out_of_bare_except_blocks    z2JumpTestCase.test_no_jump_out_of_bare_except_blockcCsL|dz|dddWn&tyF|d|dYn0dSrrr0r r r *test_no_jump_out_of_qualified_except_blocks     z7JumpTestCase.test_no_jump_out_of_qualified_except_block)r!r,r.rIcCsv|dt|d|dWdn1s40Yt|d|dWdn1sh0YdSr^rNr0r r r test_jump_between_with_blockss   ( z*JumpTestCase.test_jump_between_with_blocksc s|dt|d4IdH |dWdIdHqR1IdHsH0Yt|d4IdH |dWdIdHq1IdHs0YdSr^rPr0r r r #test_jump_between_async_with_blockss  4z0JumpTestCase.test_jump_between_async_with_blocksc CsVz$|dW|d|ddS|d|dYdS0|ddS)Nr,r3r.r5r/r0r r r -test_no_jump_over_return_out_of_finally_blocks     z:JumpTestCase.test_no_jump_over_return_out_of_finally_blockcCsF|d|s$dD]}|dqn|d|d|ddSrsr/r:r r r 'test_no_jump_into_for_block_before_elses   z4JumpTestCase.test_no_jump_into_for_block_before_elsecsV|d|s4tdg2z3dHW}|dq6n|d|d|ddSrur<r:r r r -test_no_jump_into_async_for_block_before_elses   z:JumpTestCase.test_no_jump_into_async_for_block_before_elsecCs|tdddgdS)Nr,ZSpamT)rrrr r r test_no_jump_to_non_integerssz)JumpTestCase.test_no_jump_to_non_integerscCs tdSr)rrr r r #test_no_jump_without_trace_functionsz0JumpTestCase.test_no_jump_without_trace_functioncCs0i}tdd||d}||dddgdS)Nadef f(output): # line 0 x = 0 # line 1 y = 1 # line 2 ''' # line 3 %s # lines 4-1004 ''' # line 1005 x += 1 # line 1006 output.append(x) # line 1007 return)a rr,ir)rr)r drr r r test_large_functions z JumpTestCase.test_large_functioncsjtdddGfddd}t|dd}t|jdgi}t|td|gd |ddS) Nzd # Comments don't count. output.append(2) # firstlineno is here. output.append(3) output.append(4) z rcseZdZZdS)z.fake_functionN)rrrrr rr r fake_function srr,rr)r,r9r,r9r3)compiler rRrSr|rr)r rrrr rr test_jump_to_firstlinenos    z%JumpTestCase.test_jump_to_firstlinenor$z5can't jump from the 'call' trace event of a new frame)r~r!cs*dfdd}|ddS)Nr!csddS)Nr9r/r r0r r nested-sz3JumpTestCase.test_no_jump_from_call..nestedr.r/)rrr r0r test_no_jump_from_call)s  z#JumpTestCase.test_no_jump_from_callr(z'can only jump from a 'line' trace eventcCs|ddSr r/r0r r r test_no_jump_from_return_event2s z+JumpTestCase.test_no_jump_from_return_eventrPcCs|ddddS)Nr!rr/r0r r r !test_no_jump_from_exception_event8s z.JumpTestCase.test_no_jump_from_exception_event)r~cs$fdd}t|ddS)Nc3sddVdS)Nr,r9r/r r0r r gen@s z.JumpTestCase.test_jump_from_yield..genr.)rr)rrr r0r test_jump_from_yield>s  z!JumpTestCase.test_jump_from_yield)Nr&F)Nr&F)Nr&)Nr&)\rrrrrrr#r,r-r1r2r7r8r;r=r>r?r@rZrBrErrFrGrHrIrKrMrOrQrSrUrVrWr\r]r_r`rbrcrerfrhrirkrnrorprrrtrvrwryr|r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r rBsX                                                                                   r__main__).r&rZunittestrRrr functoolsrr"rrrr"rur*r0r1r7r?rCrEr$rMrNrXrYr[r\r^rdrerfrirrZTestCaserrZ cpython_onlyrrr rrrrmainr r r r s                   J `&