a ze4S@sddlZddlZddlmZddlmZmZdddddd d d d d eejejfde fdde fde fde fde fde fgZ Gddde Z Gdddej ZedkredS)N)support)VALID_UNDERSCORE_LITERALSINVALID_UNDERSCORE_LITERALS)0r)1)9 )10 )Z99c)100d)Z314:)z 314r)z314 r)z 314 rz 1x)z 1 rz 1   uȀc@s eZdZdS) IntSubclassN__name__ __module__ __qualname__rrA/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_int.pyrsrc@seZdZddZddZejddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZddZddZddZdd Zd!d"Zd#S)$ IntTestCasesc CsF |tdd|tdd|tdd|tdd|tdd|tdd|td d|td d|td d|td d|td ddtD]l\}}dD]^}dD]T}|||}|}|dkr|tur| }z|t||WqtyYq0qqqtdtj}t|}||dtj ||t|t|ddtjdtd}||ttd}||tdtj}||d?|dtd}||t|t tdd|tddd|tddd|ttdd|ttdd|ttdd |ttdd|ttd!d|ttd!d|td"dd#|td$dd#|td%d&d#|td'd(d#|td)d*d#|td+d,d#|td-d d#|td.d/d#|td0d1d#|td2d3d#|td4dd#|td5d6d#|td7d8d#|td9d:d#|td;dd#|tdd?d#|td@dAd#|tdBdCd#|tdDdEd#|tdFdGd#|tdHdId#|tdJdKd#|tdLdMd#|tdNdOd#|tdPdQd#|tdRdSd#|tdTdUd#|tdVdWd#|tdXdYd#|tdZd[d#|td\d]d#|td^d_d#|td`dad#|tdbdcd#|tdddd|tdddd|tdedd|tddd|tddd|tdfdd&|tdgdd|tdhdd|tdidd&|tdjdk|tdjd1dk|tddd|tdd d|tdfdd&|tdldd|tdmd d|tdndd&|ttdod|ttdpd|ttdqd|ttdrd|ttdsd |ttdtd |ttdud |ttdvd |ttdwd|ttdxd|ttdyd|ttdzd|td{dd||td}dd||td~d&d||tdd(d||tdd*d||tdd,d||tdd d||tdd/d||tdd1d||tdd3d||tddd||tdd6d||tdd8d||tdd:d||tddd||tdd=d||tdd?d||tddAd||tddCd||tddEd||tddGd||tddId||tddKd||tddMd||tddOd||tddQd||tddSd||tddUd||tddWd||tddYd||tdd[d||tdd]d||tdd_d||tddad||tddcd|dS)NrgQ @gQ g333333@g333333g @g z-3z -3 u -3 r )r+-)rr rrrg}Ô%ITg}Ô%IAX111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 Z0o123rSZ0x123i#0xZ0oZ0bZ!100000000000000000000000000000000lZ102002022201221111211Z10000000000000000Z32244002423141Z 1550104015504Z 211301422354Z 40000000000Z 12068657454r Z 4294967296r Z 1904440554 Z 9ba461594Z 535a79889 Z 2ca5b7464Z 1a20dcd81Z 100000000Za7ffda91Z704he7g4Z4f5aff66Z3723ai4gZ281d55i4Z1fj8b184Z1606k7icZmb994agZhek2mglZdnchbnmZb28jpdmZ8pfgih4Z76beiggZ5qmcpqgZ4q0jto4Z4000000 Z3aokq94!Z2qhxjli"Z2br45qb#Z1z141z4$z 0o123 Z000Z0b100z 0O123 z 0X123 z 0B100 Z0123{Z0X123Z0O123Z0B100Z0b2Z0b02Z0B2Z0B02Z0o8Z0o08Z0O8Z0O08Z0xgZ0x0gZ0XgZ0X0gZ!100000000000000000000000000000001lZ102002022201221111212Z10000000000000001Z32244002423142Z 1550104015505Z 211301422355Z 40000000001Z 12068657455Z 4294967297Z 1904440555Z 9ba461595Z 535a7988aZ 2ca5b7465Z 1a20dcd82Z 100000001Za7ffda92Z704he7g5Z4f5aff67Z3723ai4hZ281d55i5Z1fj8b185Z1606k7idZmb994ahZhek2mgmZdnchbnnZb28jpdnZ8pfgih5Z76beighZ5qmcpqhZ4q0jto5Z4000001Z3aokq95Z2qhxjljZ2br45qcZ1z141z5) assertEqualintL ValueErrorreprsysmaxsizeZassertIsInstance assertRaises TypeError)selfsvsignprefixssZvvxrrr test_basic"s        zIntTestCases.test_basicc stD]RtfdddDr q|tdt|tdtdddqtD],tfdddDrxq\|ttdq\|tdd d |td d |td d |ttd|ttd|ttd|ttddS)Nc3s|]}|vVqdSNr.0ZchZlitrr z0IntTestCases.test_underscores..z.eEjJr_rc3s|]}|vVqdSrUrrVrXrrrYrZZ1_00rr Z0_100rs1_00Z_100z+_100Z1__00Z100_) ranyrDrEevalreplacerrKrGrMrrXrtest_underscoress "zIntTestCases.test_underscorescCsD|tdd|tdd|tdd|tdddS)Nr r z-1r!s10s-1)assertIsrEr_rrrtest_small_intsszIntTestCases.test_small_intscCs|tddS)NrrDrEr_rrr test_no_argsszIntTestCases.test_no_argscCs|tdddd|tdtddWdn1s@0Y|tdtdddWdn1sx0Y|jttd d|jttd ddS) Nr r"baser'zkeyword argumentg333333?)rS)rSrfr r)rDrEassertRaisesRegexrLrKr_rrrtest_keyword_argss(*zIntTestCases.test_keyword_argscCsR|tddd|ttddWdn1s<0Y|ttddWdn1sp0Y|ttddWdn1s0Y|t$tddddd Wdn1s0Y|t tdddd Wdn1s0YtddD]}|td|d dq2dS) Nrr(rr%isr"re)rDrErKrGrange)rMrfrrrtest_int_base_limitss ( ( ( 2 0z!IntTestCases.test_int_base_limitscCsl|ttddWdn1s*0Y|ttddWdn1s^0YdS)Nrg@g@)rKrLrEr_rrrtest_int_base_bad_typess ( z$IntTestCases.test_int_base_bad_typesc CsGdddt}dddd ddfD]8}|ttd|Wdq&1sT0Yq&|td|dd d |td|d d d |td|d d ddS)Nc@seZdZddZddZdS)z9IntTestCases.test_int_base_indexable..MyIndexablecSs ||_dSrUvalue)rMrorrr__init__szBIntTestCases.test_int_base_indexable..MyIndexable.__init__cSs|jSrUrnr_rrr __index__szCIntTestCases.test_int_base_indexable..MyIndexable.__index__N)rrrrprqrrrr MyIndexablesrrr"rrriZ43Z101rer(r erBi)objectrKrGrErD)rMrrrfrrrtest_int_base_indexables *z$IntTestCases.test_int_base_indexablec snGdddtGdddt}Gdddt}ttfdd||tg}zd d lmWntyjYn0|fd d|D]}|d }|t|| t |d t |tttfr| t |ddn0YWdq1s^0YqdS)Nc@s eZdZdS)z.CustomStrNrrrrr CustomStr-rZrvc@s eZdZdS)z>IntTestCases.test_non_numeric_input_types..CustomBytesNrrrrr CustomBytes.rZrwc@s eZdZdS)zBIntTestCases.test_non_numeric_input_types..CustomByteArrayNrrrrrCustomByteArray/rZrxcs |SrU)decodeb)rvrr4rZz;IntTestCases.test_non_numeric_input_types..rarraycs d|S)NBrrzr}rrr|>rZs100rr"r'zcan't convert non-stringzinvalid literalsAAAAAAAAAAAAAAAA)strbytes bytearray memoryviewr~ ImportErrorappendZsubTesttyperDrE isinstancergrLrG)rMrwrxZ factoriesfrSmsgr)rvr~rtest_non_numeric_input_types*s4  *z)IntTestCases.test_non_numeric_input_typescCs|ttdddd|ttdddd|ttdddd|ttdddd|ttdddddS) Ns123rrr5123s123 s123As1234)rDrErr_rrrtest_int_memoryviewMs z IntTestCases.test_int_memoryviewcCs|ttddS)Nz1.2)rKrGrEr_rrrtest_string_floatTszIntTestCases.test_string_floatc sbGddd}|tt|Gdddt}|tt|Gddd}|t|dGdd d }t|fD]}Gd d d |}|t|dGd d d |}|t|dGddd|}|tt|Wdn1s0Yt|fD]N} Gddd| Gfddd|} |t| dGddd| Gfddd|} |t| dGfddd| Gfddd|} zt| Wn6ty} z|t| dWYd} ~ nd} ~ 00|d|| ffGddd| Gfd d!d!|}|tt|Wdn1sN0Yq qtdS)"Nc@s eZdZdS)z>IntTestCases.test_intconversion..ClassicMissingMethodsNrrrrrClassicMissingMethodsYsrc@s eZdZdS)z7IntTestCases.test_intconversion..MissingMethodsNrrrrrMissingMethods]src@seZdZddZdS)z-IntTestCases.test_intconversion..Foo0cSsdSN*rr_rrr__int__bsz5IntTestCases.test_intconversion..Foo0.__int__NrrrrrrrrFoo0asrrc@s eZdZdS)z0IntTestCases.test_intconversion..ClassicNrrrrrClassicgsrc@seZdZddZddZdS)z:IntTestCases.test_intconversion..IntOverridesTrunccSsdSrrr_rrrrkszBIntTestCases.test_intconversion..IntOverridesTrunc.__int__cSsdS)Nirr_rrr __trunc__mszDIntTestCases.test_intconversion..IntOverridesTrunc.__trunc__N)rrrrrrrrrIntOverridesTruncjsrc@seZdZddZdS)z2IntTestCases.test_intconversion..JustTrunccSsdSrrr_rrrrrsz.JustTrunc.__trunc__Nrrrrrrrr JustTruncqsrc@seZdZddZdS)z9IntTestCases.test_intconversion..ExceptionalTrunccSs dddS)Nrrrr_rrrrwszCIntTestCases.test_intconversion..ExceptionalTrunc.__trunc__NrrrrrExceptionalTruncvsrc@seZdZddZdS)z.IntTestCases.test_intconversion..IndexcSsdSrrr_rrrrq~sz8IntTestCases.test_intconversion..Index.__index__NrrrrqrrrrIndex}srcseZdZfddZdS)z;IntTestCases.test_intconversion..TruncReturnsNonIntcsSrUrr_rrrrszEIntTestCases.test_intconversion..TruncReturnsNonInt.__trunc__NrrrrrTruncReturnsNonIntsrc@seZdZddZdS)z0IntTestCases.test_intconversion..IntablecSsdSrrr_rrrrsz8IntTestCases.test_intconversion..Intable.__int__NrrrrrIntablesrcseZdZfddZdS)z=IntTestCases.test_intconversion..TruncReturnsNonIndexcsSrUrr_rrrrszGIntTestCases.test_intconversion..TruncReturnsNonIndex.__trunc__NrrrrrTruncReturnsNonIndexsrcseZdZfddZdS)z4IntTestCases.test_intconversion..NonIntegralcsSrUrr_ NonIntegralrrrsz>IntTestCases.test_intconversion..NonIntegral.__trunc__NrrrrrrsrcseZdZfddZdS)z@IntTestCases.test_intconversion..TruncReturnsNonIntegralcsSrUrr_rrrrszJIntTestCases.test_intconversion..TruncReturnsNonIntegral.__trunc__NrrrrrTruncReturnsNonIntegralsrz2__trunc__ returned non-Integral (type NonIntegral)z!Failed to raise TypeError with %sc@seZdZddZdS)z/IntTestCases.test_intconversion..BadIntcSsdSNgE@rr_rrrrsz7IntTestCases.test_intconversion..BadInt.__int__NrrrrrBadIntsrcseZdZfddZdS)z;IntTestCases.test_intconversion..TruncReturnsBadIntcsSrUrr_rrrrszEIntTestCases.test_intconversion..TruncReturnsBadInt.__trunc__NrrrrrTruncReturnsBadIntsr)rKrLrErtrDZeroDivisionErrorrZfail)rMrrrrrfrrrZtrunc_result_baserrrerr)rrrrrtest_intconversionWsJ (  zIntTestCases.test_intconversioncCsZGdddt}Gdddt}|d}||d|t|d|t|ddS)Nc@seZdZddZdS)z:IntTestCases.test_int_subclass_with_index..MyIndexcSsdSrrr_rrrrqszDIntTestCases.test_int_subclass_with_index..MyIndex.__index__NrrrrrMyIndexsrc@seZdZddZdS)z;IntTestCases.test_int_subclass_with_index..BadIndexcSsdSrrr_rrrrqszEIntTestCases.test_int_subclass_with_index..BadIndex.__index__NrrrrrBadIndexsrr*r)rErD)rMrrmy_intrrrtest_int_subclass_with_indexs  z)IntTestCases.test_int_subclass_with_indexcCsjGdddt}Gdddt}|d}||d|t|d|d}||d|tt|dS)Nc@seZdZddZdS)z6IntTestCases.test_int_subclass_with_int..MyIntcSsdSrrr_rrrrsz>IntTestCases.test_int_subclass_with_int..MyInt.__int__NrrrrrMyIntsrc@seZdZddZdS)z7IntTestCases.test_int_subclass_with_int..BadIntcSsdSrrr_rrrrsz?IntTestCases.test_int_subclass_with_int..BadInt.__int__Nrrrrrrsrr*r)rErDrKrL)rMrrrrrrtest_int_subclass_with_ints  z'IntTestCases.test_int_subclass_with_intc sGdddGdddt}GdddGdddt}Gfd d d }Gfd d d }Gd dd}}|tt|}Wdn1s0Y||d|t|t|}t|}||d|t|t}|tt|}Wdn1s0Y||d|t|t|}|tt|}Wdn1sr0Y||d|t|t|}|tt|}Wdn1s0Y||d|t|t|}|tt|}Wdn1s0Y||d|t|t|}t|}||d|t|tt|}||d|t|tdS)Nc@seZdZddZdS)z.BadIndexcSsdSNTrr_rrrrqszFIntTestCases.test_int_returns_int_subclass..BadIndex.__index__Nrrrrrrsrc@seZdZddZdS)z=IntTestCases.test_int_returns_int_subclass..BadIndex2cSsdSrrr_rrrrqszGIntTestCases.test_int_returns_int_subclass..BadIndex2.__index__Nrrrrr BadIndex2src@seZdZddZdS)z:IntTestCases.test_int_returns_int_subclass..BadIntcSsdSrrr_rrrrszBIntTestCases.test_int_returns_int_subclass..BadInt.__int__Nrrrrrrsrc@seZdZddZdS)z;IntTestCases.test_int_returns_int_subclass..BadInt2cSsdSrrr_rrrrszCIntTestCases.test_int_returns_int_subclass..BadInt2.__int__NrrrrrBadInt2srcseZdZfddZdS)zHIntTestCases.test_int_returns_int_subclass..TruncReturnsBadIndexcsSrUrr_rrrrszRIntTestCases.test_int_returns_int_subclass..TruncReturnsBadIndex.__trunc__NrrrrrTruncReturnsBadIndexsrcseZdZfddZdS)zFIntTestCases.test_int_returns_int_subclass..TruncReturnsBadIntcsSrUrr_rrrrszPIntTestCases.test_int_returns_int_subclass..TruncReturnsBadInt.__trunc__Nrrrrrrsrc@seZdZddZdS)zKIntTestCases.test_int_returns_int_subclass..TruncReturnsIntSubclasscSsdSrrr_rrrrszUIntTestCases.test_int_returns_int_subclass..TruncReturnsIntSubclass.__trunc__NrrrrrTruncReturnsIntSubclasssrrr)rEZ assertWarnsDeprecationWarningrDrarr) rMrrrrrZbad_intnZgood_intr)rrrtest_int_returns_int_subclasssV &   (  (  (  (   z*IntTestCases.test_int_returns_int_subclasscsdfdd }|d|d|d|d|dd|dd |dd |d d |d d |d |d d|d |d d|d|dddS)Ncs~jtd||fd,}|dur*t|n t||Wdn1sH0Y|jjdd|durndn||fdS)Nz int(%r, %r))rrz*invalid literal for int() with base %d: %rr )rKrGrErD exceptionargs)rNrfcmr_rrchecks  (z.IntTestCases.test_error_message..check½u123½z 123 456 z123r z123 245r2rz123245rs123u123)Nr)rMrrr_rtest_error_messages         zIntTestCases.test_error_messagecCsL|tddd|tddd|tddd |td d d dS) NZ=1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1r"iUUUUZ1_2_3_4_5_6_7_0_1_2_3r&iSpSZ1_2_3_4_5_6_7_8_9rlgFZ 1_2_3_4_5_6_7r>i2Drcr_rrrtest_issue316196s  zIntTestCases.test_issue31619N)rrrrTr`rZ cpython_onlyrbrdrhrlrmrurrrrrrrrrrrrrr s&8  #VH!r__main__)rIZunittesttestrZtest.test_grammarrrrHrJrGrFrErZTestCaserrmainrrrrs< "