ó {G_Tc@s¤ddlZddlZddlZddlZddlmZddlZdejfd„ƒYZdejfd„ƒYZ d„Z e dkr ej ƒndS( iÿÿÿÿN(t test_supportt TestSpecificscBseZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„ZejdkrÃd„Znd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs$tdddƒtdddƒdS(Nthistexecshi (tcompile(tself((s-/usr/local/lib/python2.7/test/test_compile.pyttest_no_ending_newline scCstdddƒdS(NtsR(R(R((s-/usr/local/lib/python2.7/test/test_compile.pyt test_emptyscCsDtdddƒtdddƒtdddƒtdddƒdS(Ns sRs shi stuff def f(): pass s(this_is really_old_mac def f(): pass(R(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_other_newlinesscCsR|jttdddƒddl}|j}t|ddƒt|d|ƒdS(Ns __debug__ = 1t?tsingleiÿÿÿÿt __debug__tsure(t assertRaisest SyntaxErrorRt __builtin__R tsetattr(RRtprev((s-/usr/local/lib/python2.7/test/test_compile.pyttest_debug_assignments   cBsÄ|jeedƒ|jeedƒ|jeedƒyddU|jdƒWnek renXyddU|jdƒWnek r’nXyddU|jd ƒWnek r¿nXdS( Ns lambda a,a:0slambda a,a=1:0slambda a=1,a=1:0sdef f(a, a): passsduplicate argumentssdef f(a = 0, a = 1): passsduplicate keyword argumentssdef f(a): global a; a = 1svariable is global and local(RRtevaltfail(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_argument_handlings$   cCs|jttdddƒdS(Ns1+*3tfilenameR(RRR(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_syntax_error4scCs|jttdddƒdS(Ns f(None=1)sR(RRR(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_none_keyword_arg7scBs1yddU|jdƒWnek r,nXdS(Nsdef f(a): global a; a = 1svariable is global and local(RR(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_duplicate_global_local:s  c Bs8idd6}d|fdU|j|ddƒidd6}idd6dd6}d ||fdU|jd|ƒ|j|dd ƒ|jeƒ d dUWdQX|jeƒdiiifdUWdQXidd6d d6}i}|jeƒd|f|UWdQX|jeƒd||f||UWdQXdS( Nitbs a = b + 1taiiitcs a = b + ci i(s a = b + 1(t assertEqualt assertNotInRt TypeError(Rtgtl((s-/usr/local/lib/python2.7/test/test_compile.pyttest_exec_functional_styleAs$  cBs™ddd„ƒY}|ƒ}eƒ}d||U|j|jdƒyd||UWnek rcnX|jdƒd||U|j|jded ƒfƒd ||U|j|jd|fƒd ||U|j|jd|fƒy d|UWnek rÿnX|jd ƒd dd„ƒY}|ƒ}yd||UWnek rJnX|jdƒdefd„ƒY}|ƒ}d||U|j|ddƒdS(NtMcBs)eZdZd„Zd„Zd„ZRS(s9Test mapping interface versus possible calls from eval().cSs|dkrdSt‚dS(NRi (tKeyError(Rtkey((s-/usr/local/lib/python2.7/test/test_compile.pyt __getitem__as cSs||f|_dS(N(tresults(RR&tvalue((s-/usr/local/lib/python2.7/test/test_compile.pyt __setitem__escSs tdƒS(Ntxyz(tlist(R((s-/usr/local/lib/python2.7/test/test_compile.pytkeysgs(t__name__t __module__t__doc__R'R*R-(((s-/usr/local/lib/python2.7/test/test_compile.pyR$_s  sz = atzi sz = bsDid not detect a KeyErrors z = dir()R+s z = globals()s z = locals()s'Did not validate globals as a real dicttAcBseZdZRS(s Non-mapping(R.R/R0(((s-/usr/local/lib/python2.7/test/test_compile.pyR2ss$Did not validate locals as a mappingtDcBseZd„ZRS(cSs |dkrdStj||ƒS(NRi (tdictR'(RR&((s-/usr/local/lib/python2.7/test/test_compile.pyR'Žs (R.R/R'(((s-/usr/local/lib/python2.7/test/test_compile.pyR3s((R1i ((tglobalsRR(t NameErrorRR,R R4(RR$tmR!R2R3td((s-/usr/local/lib/python2.7/test/test_compile.pyt)test_exec_with_general_mapping_for_locals]s@                cBsAddd}d|fd}|dU|jedƒdƒdS(Ns x = x or s-xiÄ sÞ def f(x): %s %s %s %s %s %s %s %s %s %s # the expressions above have no effect, x == argument while x: x -= 1 # EXTENDED_ARG/JUMP_ABSOLUTE here return x i ii(Rtf(Rtlongexprtcode((s-/usr/local/lib/python2.7/test/test_compile.pyttest_extended_arg–scBs1ejdefƒejdƒdUWdQXdS(Ns*tuple parameter unpacking has been removeds> def comp_args((a, b)): return a,b self.assertEqual(comp_args((1, 2)), (1, 2)) def comp_args((a, b)=(3, 4)): return a, b self.assertEqual(comp_args((1, 2)), (1, 2)) self.assertEqual(comp_args(), (3, 4)) def comp_args(a, (b, c)): return a, b, c self.assertEqual(comp_args(1, (2, 3)), (1, 2, 3)) def comp_args(a=2, (b, c)=(3, 4)): return a, b, c self.assertEqual(comp_args(1, (2, 3)), (1, 2, 3)) self.assertEqual(comp_args(), (2, 3, 4)) (Rtcheck_py3k_warningst SyntaxWarningttextwraptdedent(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_complex_args­scBs1yddU|jdƒWnek r,nXdS(Nsdef f(a=1, (b, c)): passsnon-default args after default(RR(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_argument_orderÅs  cCsP|jttdƒ|jttdƒ|jttdƒ|jttdƒdS(Nt2es2.0e+s1e-s3-4e/21(RRR(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_float_literalsÌscCsd}t|ddƒdS(Ns if 1: if 2: passsR(R(Rts((s-/usr/local/lib/python2.7/test/test_compile.pyttest_indentationÓscCsYdjdgddgƒ}t|ddƒ}|j|jdƒ|j|jdƒdS(NRs itspamtfnRi(tjoinRRtco_firstlinenot co_lnotab(Rts256tco((s-/usr/local/lib/python2.7/test/test_compile.pyttest_leading_newlinesßscCs!xZddddddddd d d d d ddddddgD]}|jtt|ƒq@W|jtdƒdƒ|jtdƒdƒ|jtdƒdƒ|jtdƒdƒ|jtdƒdƒ|jtdƒdƒ|jtdƒdƒ|jtdƒdƒ|jtdƒdƒ|jtd ƒd!ƒ|jtd"ƒd#ƒ|jtd$ƒd#ƒ|jtd%ƒd&ƒ|jtd'ƒd(ƒ|jtd)ƒd*ƒ|jtd+ƒd#ƒ|jtd,ƒd#ƒ|jtd-ƒd.ƒ|jtd/ƒd.ƒ|jtd0ƒd.ƒ|jtd1ƒd.ƒ|jtd2ƒd3ƒ|jtd4ƒd5ƒ|jtd6ƒd7ƒ|jtd8ƒd9ƒ|jtd:ƒd;ƒ|jtd<ƒd=ƒ|jtd>ƒdƒ|jtd?ƒd@ƒ|jtdAƒdBƒ|jtdCƒdDƒ|jtdEƒdFƒdS(GNt077787t0xjs0x.t0et090000000000000t080000000000000t000000000000009t000000000000008t0b42t0BADCAFEt 0o123456789s0b1.1s0o4.2t0b101j2t0o153j2t0b100e1t0o777e1t0o8t0o78t0777iÿt0777Lt000777t0xffiÿt0xffLt0XfFs0777.i s0777.0t8000000000000000000000000000000000000000000000000000777e0t0777e1iZt0e0is 0000E-012s09.5g#@t0777jyHˆ@t00jys00.0t0e3s090000000000000.gè°vÔBs&090000000000000.0000000000000000000000t090000000000000e0s090000000000000e-0t090000000000000jyè°vÔBt000000000000007is000000000000008.g @s000000000000009.g"@t0b101010i*s-0b000000000010iþÿÿÿt0o777s -0o0000010iøÿÿÿs020000000000.0g _ Bt037777777777e0gâHv—!Bs01000000000000000000000.0gPïâÖäKD(RRRR(Rtarg((s-/usr/local/lib/python2.7/test/test_compile.pyt!test_literals_with_leading_zeroesåsL cCsåtjdkrHd}|jt|ƒdƒ|jtd|ƒdƒnUtjdkrd}|jt|ƒdƒ|jtd|ƒd ƒn |jd ƒ|jtd tj d ƒtƒ|jtd tj d ƒtƒdS(Niÿÿÿt 0xfffffffflÿÿt-lýÿÿÿÿÿIÿÿÿÿÿÿÿt0xfffffffffffffffflÿÿÿÿlûÿÿÿÿÿÿÿs)How many bits *does* this machine have???s%sii(tsystmaxintRRRtassertIsInstancetinttlong(Rt all_one_bits((s-/usr/local/lib/python2.7/test/test_compile.pyttest_unary_minuss "Iÿÿÿÿÿÿÿc Csqd }d}d }d}d }d}d }d}x6|jjjD]%} | dk rD|j| tƒqDqDWdS( NIIÿÿÿÿIIÿÿI@IÀIÿÿÿÿÿÿÿI€(ttest_32_63_bit_valuest func_codet co_conststNoneRyRz( RRRRR8teR:R!thtvariable((s-/usr/local/lib/python2.7/test/test_compile.pyR~"s cCs6dp d\}}|j|dƒ|j|dƒdS(Niiÿÿÿÿ(iiÿÿÿÿ(iÿÿÿÿi(R(Rtitj((s-/usr/local/lib/python2.7/test/test_compile.pyttest_sequence_unpacking_error0sc Cs«ddddddddd d d d g }xJ|D]B}|d 7}|jtt|ddƒ|jtt|ddƒq1WtdddƒtdddƒtdddƒdS(NsNone = 0s None += 0s__builtins__.None = 0sdef None(): passsclass None: passs(a, None) = 0, 0sfor None in range(10): passsdef f(None): passs import Nonesimport x as Nonesfrom x import Nonesfrom x import y as Nones ttmpR Rsfrom None import xsfrom x import None as ysimport None as x(RRR(Rtstmtststmt((s-/usr/local/lib/python2.7/test/test_compile.pyttest_none_assignment6s&   cCsÇddddddddd d d d d ddg}ddddddddddddddddd d!d"d#d$g}x|D]}t|d%d&ƒqWx'|D]}|jtt|d%d&ƒq WdS('Ns import syssimport os, syssimport os as barsimport os.path as bars0from __future__ import nested_scopes, generatorss2from __future__ import (nested_scopes, generators)s3from __future__ import (nested_scopes, generators,)s%from sys import stdin, stderr, stdouts'from sys import (stdin, stderr, stdout)s(from sys import (stdin, stderr, stdout,)s(from sys import (stdin , stderr, stdout)s)from sys import (stdin , stderr, stdout,)s7from sys import stdin as si, stdout as so, stderr as ses9from sys import (stdin as si, stdout as so, stderr as se)s:from sys import (stdin as si, stdout as so, stderr as se,)simport (os, sys)simport (os), (sys)simport ((os), (sys))s import (syss import sys)s import (os,)simport os As barsimport os.path a barsfrom sys import stdin As stdoutsfrom sys import stdin a stdoutsfrom (sys) import stdins%from __future__ import (nested_scopess%from __future__ import nested_scopes)s0from __future__ import nested_scopes, generatorssfrom sys import (stdinsfrom sys import stdin)s%from sys import stdin, stdout, stderrsfrom sys import stdin sis)from sys import stdin,from sys import (*)s(from sys import (stdin,, stdout, stderr)s from sys import (stdin, stdout),RˆR(RRR(RtsucceedRRŠ((s-/usr/local/lib/python2.7/test/test_compile.pyt test_importNsP    cCs>d„}|ƒ\}}|jt|jƒt|jƒƒdS(NcSs"dd„}dd„}||fS(NicSs|S(N((tx((s-/usr/local/lib/python2.7/test/test_compile.pyt€sicSs|S(N((RŽ((s-/usr/local/lib/python2.7/test/test_compile.pyRs((tf1tf2((s-/usr/local/lib/python2.7/test/test_compile.pyR:s  (tassertNotEqualtidR(RR:RR‘((s-/usr/local/lib/python2.7/test/test_compile.pyttest_for_distinct_code_objects}s cCsd„}|j|jƒdS(NcSsdS(Ntfoo((((s-/usr/local/lib/python2.7/test/test_compile.pyR‡s(t assertIsNoneR0(RR"((s-/usr/local/lib/python2.7/test/test_compile.pyttest_lambda_doc†s cCs#d}|jtt|ddƒdS(Nu# -*- coding: utf-8 -*- pass RˆR(RRR(RR<((s-/usr/local/lib/python2.7/test/test_compile.pyttest_unicode_encodingŠscCsJdtfd„ƒY}|ƒ}d|d<|j|ddƒ|dcd7<|j|ddƒ|d=|jd|ƒd|d<|j|ddƒ|d cd7<|j|d dƒ|d =|jd |ƒd|dd+|j|dd!dƒ|ddc!d7+|j|dd!dƒ|dd5|jtddƒ|ƒd|dd…dd…f<|j|dd…dd…fdƒ|dd…dd…fcd7<|j|dd…dd…fdƒ|dd…dd…f=|jtddƒtddƒf|ƒd|ddd…<|j|ddd…dƒ|ddd…cd7<|j|ddd…dƒ|ddd…=|jtdddƒ|ƒd|ddd…ddd…f<|j|ddd…ddd…fdƒ|ddd…ddd…fcd7<|j|ddd…ddd…fdƒ|ddd…ddd…f=|jtdddƒtdddƒf|ƒd|d<|j|ddƒ|dcd7<|j|ddƒ|d=|jt|ƒd|d <|j|ddƒ|dcd7<|j|ddƒ|d=|jttf|ƒdS(Ntstr_mapcBs5eZd„Zd„Zd„Zd„Zd„ZRS(cSs i|_dS(N(tdata(R((s-/usr/local/lib/python2.7/test/test_compile.pyt__init__’scSs|jt|ƒS(N(Rštstr(RR&((s-/usr/local/lib/python2.7/test/test_compile.pyR'”scSs||jt|ƒsx = 5ssprint 1ssprint vs s print Trues sprint []s sif True: pass s s for n in [1, 2, 3]: print n s sdef foo(): pass foo() s%s1Rs%s2s%s3ssR(R«R¬(t__file__tlowertendswithtopentreadRt_astt PyCF_ONLY_ASTt assertTruettypetModuleRt co_filenameRR tIftBoolOptbody( RtfnameR:t fcontentst sample_codeR<tco1tasttco2((s-/usr/local/lib/python2.7/test/test_compile.pyttest_compile_astãs6          ( R.R/RRR RRRRRR#R9R=RBRCRERGRORsR}RwRxR~R‡R‹RR”R—R˜R¢RªRÂ(((s-/usr/local/lib/python2.7/test/test_compile.pyRs:          9      )     /   H t TestStackSizecBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( idcCs\t|tƒr$t|ddƒ}ntjtjt|jƒƒƒ}|j|j |ƒdS(NsR ( t isinstanceRœRtmathtceiltlogtlentco_codetassertLessEqualt co_stacksize(RR<tmax_size((s-/usr/local/lib/python2.7/test/test_compile.pytcheck_stack_sizes!cCs|jd|jdƒdS(Nsx and RŽ(RÍtN(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_andscCs|jd|jdƒdS(Nsx or RŽ(RÍRÎ(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_orscCs|jd|jdƒdS(Ns x and x or RŽ(RÍRÎ(R((s-/usr/local/lib/python2.7/test/test_compile.pyt test_and_orscCs|jd|jdƒdS(Nsx < RŽ(RÍRÎ(R((s-/usr/local/lib/python2.7/test/test_compile.pyttest_chained_comparison"scCs|jd|jdƒdS(Ns x if x else RŽ(RÍRÎ(R((s-/usr/local/lib/python2.7/test/test_compile.pyt test_if_else%scCs|jd|jdƒdS(Nsx + RŽ(RÍRÎ(R((s-/usr/local/lib/python2.7/test/test_compile.pyt test_binop(scCs(d}|d|j7}|j|ƒdS(Ns def f(x): s x and x (RÎRÍ(RR<((s-/usr/local/lib/python2.7/test/test_compile.pyt test_func_and+s( R.R/RÎRÍRÏRÐRÑRÒRÓRÔRÕ(((s-/usr/local/lib/python2.7/test/test_compile.pyRà s       cCstjtƒdS(N(Rt run_unittestR.(((s-/usr/local/lib/python2.7/test/test_compile.pyt test_main1st__main__( RÅtunittestRwR³ttestRR@tTestCaseRRÃR×R.tmain(((s-/usr/local/lib/python2.7/test/test_compile.pyts     ÿÿ&