ó {G_Tc@sÆddlmZddlZddlZddlZejZdadd„Zdej fd„ƒYZ dej fd„ƒYZ d ej fd „ƒYZ dd „Z ed krÂe d eƒndS(iÿÿÿÿ(t test_supportNicCsþtrdG|GHn|}|r/|j|ƒn |jƒt|ƒt|ƒkrdG|GHdGt|ƒGt|ƒGH|GH|GH|GHtd7adSxgt|ƒD]Y\}}||}||k rdG|GHdG|G|G|GH|GH|GH|GHtd7adSqWdS(Ns checkingserror inslength mismatch;isout of order at index(tverbosetsorttlentnerrorst enumerate(ttagtexpectedtrawtcomparetorigtitgoodtmaybe((s*/usr/local/lib/python2.7/test/test_sort.pytcheck s0        tTestBasecBseZd„ZRS(c s¢dg}x?tddƒD].}d|}|jt|d|dƒƒqW|jdddgƒdtf‡fd†ƒY‰d tfd „ƒY}x|D]}t|ƒ}tr¾d G|GHn|}td ||ƒ|}|jƒtd ||ƒ|}tj|ƒtd||ƒ|}|jƒ|}td||d„ƒtr[dGHdGHn|}|jd„ƒtd||ƒg|D]}ˆ|ƒ^q‰}|}tj|ƒt ˆ_ t } y|jƒWnt k rët } nX| rt ˆ_ td||ƒngt |ƒD]}|tjdƒ|ƒ^q}g|D]} | | jf^qF} | jƒg| D]\} }| ^qr}td||ƒqšWdS(Niii iidièt Complainscs/eZeZd„Z‡fd†Zd„ZRS(cSs ||_dS(N(R (tselfR ((s*/usr/local/lib/python2.7/test/test_sort.pyt__init__5scsJˆjr:tjƒdkr:tr1dG|G|GHnt‚n|j|jkS(Ngü©ñÒMbP?s complaining at(tmaybe_complaintrandomRt RuntimeErrorR (Rtother(R(s*/usr/local/lib/python2.7/test/test_sort.pyt__lt__8s  cSs d|jS(Ns Complains(%d)(R (R((s*/usr/local/lib/python2.7/test/test_sort.pyt__repr__?s(t__name__t __module__tTrueRRRR((R(s*/usr/local/lib/python2.7/test/test_sort.pyR2s tStablecBs)eZd„Zd„ZdZd„ZRS(cSs||_||_dS(N(tkeytindex(RRR ((s*/usr/local/lib/python2.7/test/test_sort.pyRCs cSst|j|jƒS(N(tcmpR(RR((s*/usr/local/lib/python2.7/test/test_sort.pyt__cmp__GscSsd|j|jfS(NsStable(%d, %d)(RR(R((s*/usr/local/lib/python2.7/test/test_sort.pyRKsN(RRRR tNonet__hash__R(((s*/usr/local/lib/python2.7/test/test_sort.pyRBs  s Testing sizetidentitytreversedsrandom permutationsreversed via functioncSs t||ƒS(N(R(tatb((s*/usr/local/lib/python2.7/test/test_sort.pytass3 Checking against an insane comparison function.s? If the implementation isn't careful, this may segfault.cSsttjƒdƒdS(Nii(tintR(R%R&((s*/usr/local/lib/python2.7/test/test_sort.pyR'gss(an insane function left some permutations+exception during sort left some permutationt stability(trangetextendtobjectRRtreverseRtshuffleRRRtFalseRtxranget randrangeR( RtsizestpowertnRtxtstyR t it_complainedtet augmented((Rs*/usr/local/lib/python2.7/test/test_sort.pyttestStressfully*s\  "           1" (RRR;(((s*/usr/local/lib/python2.7/test/test_sort.pyR)stTestBugscBs#eZd„Zd„Zd„ZRS(csRdd‡fd†ƒY}gtdƒD]}|ƒ^q&‰|jtˆjƒdS(NtCcseZ‡fd†ZRS(csBˆr%tjƒdkr%ˆjƒn ˆjdƒtjƒdkS(Ngè?igà?(Rtpoptappend(RR(tL(s*/usr/local/lib/python2.7/test/test_sort.pyR‡s  (RRR((R@(s*/usr/local/lib/python2.7/test/test_sort.pyR=†si2((R*t assertRaisest ValueErrorR(RR=R ((R@s*/usr/local/lib/python2.7/test/test_sort.pyttest_bug453523s"cCs@tdƒ}tj|ƒ|jdƒ|j|tdƒƒdS(Ni2(R*RR.RR!t assertEqual(RR@((s*/usr/local/lib/python2.7/test/test_sort.pyt test_cmpNone‘s   cs€g}xstdƒD]e}‡fd†}ddg‰|jtˆj|ƒ‡fd†}|jtˆj|ƒ|g}qWdS(Nics$ˆjdƒˆjƒt||ƒS(Ni(R?R>R(R5R7(R@(s*/usr/local/lib/python2.7/test/test_sort.pyt mutating_cmps  iicsˆjdƒˆ2t||ƒS(Ni(R?R(R5R7(R@(s*/usr/local/lib/python2.7/test/test_sort.pyRF£s (R*RARBR(Rt memorywasterR RF((R@s*/usr/local/lib/python2.7/test/test_sort.pyttest_undetected_mutation™s (RRRCRERH(((s*/usr/local/lib/python2.7/test/test_sort.pyR<s  tTestDecorateSortUndecoratecBskeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z RS( cCsJdjƒ}|}tj|ƒ|jdtjƒ|jdd„ƒdS(Ns,The quick Brown fox Jumped over The lazy DogRRcSst|jƒ|jƒƒS(N(Rtlower(R5R7((s*/usr/local/lib/python2.7/test/test_sort.pyR'³s(tsplitRR.RtstrRJ(Rtdatatcopy((s*/usr/local/lib/python2.7/test/test_sort.pyttest_decorated®s   cCs,djƒ}|jt|jdd„ƒdS(Ns,The quick Brown fox Jumped over The lazy DogcSsdS(Ni((R5R7((s*/usr/local/lib/python2.7/test/test_sort.pyR'·s(RKRAt TypeErrorRR!(RRM((s*/usr/local/lib/python2.7/test/test_sort.pyttest_baddecoratorµs cCsfgtdƒD]}tjdƒ|f^q }|}|jdd„ƒ|jƒ|j||ƒdS(NiÈidRcSs|dS(Ni((R5((s*/usr/local/lib/python2.7/test/test_sort.pyR'¼s(R0RR1RRD(RR RMRN((s*/usr/local/lib/python2.7/test/test_sort.pyttest_stability¹s . cs8‡fd†}djƒ}|jd|dtjƒdS(Ncs9ˆjt|ƒtƒˆjt|ƒtƒt||ƒS(N(RDttypeRLR(R5R7(R(s*/usr/local/lib/python2.7/test/test_sort.pyR Âss,The quick Brown fox Jumped over The lazy DogRR(RKRRLRJ(RR RM((Rs*/usr/local/lib/python2.7/test/test_sort.pyttest_cmp_and_key_combinationÀs cCs,djƒ}|jt|jdtjƒdS(Ns,The quick Brown fox Jumped over The lazy Dogtbad(RKRARPRRLRJ(RRM((s*/usr/local/lib/python2.7/test/test_sort.pyttest_badcmp_with_keyÉs cCsFtddƒ}|}|jt|jdd„ƒ|j||ƒdS(NiþÿÿÿicSsd|S(Ni((R5((s*/usr/local/lib/python2.7/test/test_sort.pyR'Òs(R*RAtZeroDivisionErrorRR!RD(RRMtdup((s*/usr/local/lib/python2.7/test/test_sort.pyttest_key_with_exceptionÎscs8tdƒ‰‡fd†}|jtˆjd|ƒdS(Ni csˆ2tdƒˆ(|S(Ni(R*(R5(RM(s*/usr/local/lib/python2.7/test/test_sort.pytk×s R(R*RARBR(RRZ((RMs*/usr/local/lib/python2.7/test/test_sort.pyttest_key_with_mutationÕs csEtdƒ‰dtf‡fd†ƒY}|jtˆjd|ƒdS(Ni t SortKillercs eZd„Z‡fd†ZRS(cSsdS(N((RR5((s*/usr/local/lib/python2.7/test/test_sort.pyRàscsˆ2tdƒˆ(dS(Ni(R*(R(RM(s*/usr/local/lib/python2.7/test/test_sort.pyt__del__âs(RRRR]((RM(s*/usr/local/lib/python2.7/test/test_sort.pyR\ßs R(R*R,RARBR(RR\((RMs*/usr/local/lib/python2.7/test/test_sort.pyttest_key_with_mutating_delÝs csEtdƒ‰dtf‡fd†ƒY}|jtˆjd|ƒdS(Ni R\cs eZd„Z‡fd†ZRS(cSs|dkrt‚ndS(Ni(R(RR5((s*/usr/local/lib/python2.7/test/test_sort.pyRës csˆ2tdƒˆ(dS(Ni(R*(R(RM(s*/usr/local/lib/python2.7/test/test_sort.pyR]îs(RRRR]((RM(s*/usr/local/lib/python2.7/test/test_sort.pyR\ês R(R*R,RARR(RR\((RMs*/usr/local/lib/python2.7/test/test_sort.pyt(test_key_with_mutating_del_and_exceptionçs cCs_tdƒ}tj|ƒ|jdtƒ|j|tdddƒƒ|jt|jdƒdS(NidR-iciÿÿÿÿs wrong type(R*RR.RRRDRARP(RRM((s*/usr/local/lib/python2.7/test/test_sort.pyt test_reverseûs   cCs¥gtdƒD]}tjdƒ|f^q }|}|}|jdd„dtƒ|jdd„ƒ|j||ƒ|jdd„dtƒ|j||ƒdS( NiÈidRcSst|d|dƒS(Ni(R(R5R7((s*/usr/local/lib/python2.7/test/test_sort.pyR'sR-cSst|d|dƒS(Ni(R(R5R7((s*/usr/local/lib/python2.7/test/test_sort.pyR'sRcSs|dS(Ni((R5((s*/usr/local/lib/python2.7/test/test_sort.pyR' s(R0RR1RRRD(RR RMtcopy1tcopy2((s*/usr/local/lib/python2.7/test/test_sort.pyttest_reverse_stabilitys.( RRRORQRRRTRVRYR[R^R_R`Rc(((s*/usr/local/lib/python2.7/test/test_sort.pyRI¬s        cCs¶tttf}tjdtfƒŒtj|Œ|r¬ttdƒr¬ddl }dgd}xAt t |ƒƒD]-}tj|Œ|j ƒtjƒ||s     V-b