Annotation of embedaddon/php/ext/standard/tests/general_functions/is_int_64bit.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test is_int() & it's FALIASes: is_long() & is_integer() functions
        !             3: --SKIPIF--
        !             4: <?php
        !             5: if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
        !             6: ?>
        !             7: --INI--
        !             8: precision=14
        !             9: --FILE--
        !            10: <?php
        !            11: /* Prototype: bool is_int ( mixed $var );
        !            12:  * Description: Finds whether the given variable is an integer  
        !            13:  */
        !            14: 
        !            15: echo "*** Testing is_int(), is_integer() & is_long()  with valid integer values ***\n";
        !            16: // different valid  integer vlaues 
        !            17: $valid_ints = array(
        !            18:   0,
        !            19:   1,
        !            20:   -1,
        !            21:   -2147483648, // max negative integer value
        !            22:   -2147483647, 
        !            23:   2147483647,  // max positive integer value
        !            24:   2147483640,
        !            25:   0x123B,      // integer as hexadecimal
        !            26:   0x12ab,
        !            27:   0Xfff,
        !            28:   0XFA,
        !            29:   -0x80000000, // max negative integer as hexadecimal
        !            30:   0x7fffffff,  // max postive integer as hexadecimal
        !            31:   0x7FFFFFFF,  // max postive integer as hexadecimal
        !            32:   0123,        // integer as octal
        !            33:   01912,       // should be quivalent to octal 1
        !            34:   -020000000000, // max negative integer as octal
        !            35:   017777777777,  // max positive integer as octal
        !            36: );
        !            37: /* loop to check that is_int() recognizes different 
        !            38:    integer values, expected output: bool(true) */
        !            39: $loop_counter = 1;
        !            40: foreach ($valid_ints as $int_val ) {
        !            41:    echo "--Iteration $loop_counter--\n"; $loop_counter++;   
        !            42:    var_dump( is_int($int_val) );
        !            43:    var_dump( is_integer($int_val) );
        !            44:    var_dump( is_long($int_val) );
        !            45: }
        !            46: 
        !            47: echo "\n*** Testing is_int(), is_integer() & is_long() with  non integer values ***\n";
        !            48: 
        !            49: // resource type variable
        !            50: $fp = fopen (__FILE__, "r");
        !            51: $dfp = opendir ( dirname(__FILE__) );
        !            52: // unset variable
        !            53: 
        !            54: $unset_var = 10;
        !            55: unset ($unset_var);
        !            56: 
        !            57: // other types in a array 
        !            58: $not_int_types = array (
        !            59:   /* float values */
        !            60:   -2147483649, // float value
        !            61:   2147483648,  // float value
        !            62:   -0x80000001, // float value, beyond max negative int
        !            63:   0x800000001, // float value, beyond max positive int
        !            64:   020000000001, // float value, beyond max positive int 
        !            65:   -020000000001, // float value, beyond max negative int 
        !            66:   0.0,  
        !            67:   -0.1,
        !            68:   1.0,
        !            69:   1e5,
        !            70:   -1e6,
        !            71:   1E8,
        !            72:   -1E9,
        !            73:   10.0000000000000000005,
        !            74:   10.5e+5,
        !            75:  
        !            76:   /* objects */
        !            77:   new stdclass,
        !            78: 
        !            79:   /* resources */
        !            80:   $fp,
        !            81:   $dfp,
        !            82:   
        !            83:   /* arrays */
        !            84:   array(),
        !            85:   array(0),
        !            86:   array(1),
        !            87:   array(NULL),
        !            88:   array(null),
        !            89:   array("string"),
        !            90:   array(true),
        !            91:   array(TRUE),
        !            92:   array(false),
        !            93:   array(FALSE),
        !            94:   array(1,2,3,4),
        !            95:   array(1 => "One", "two" => 2),
        !            96:   
        !            97:   /* strings */
        !            98:   "",
        !            99:   '',
        !           100:   "0",
        !           101:   '0',
        !           102:   "1",
        !           103:   '1',
        !           104:   "\x01",
        !           105:   '\x01',
        !           106:   "\01",
        !           107:   '\01',
        !           108:   'string',
        !           109:   "string",
        !           110:   "true",
        !           111:   "FALSE",
        !           112:   'false',
        !           113:   'TRUE',
        !           114:   "NULL",
        !           115:   'null',
        !           116: 
        !           117:   /* booleans */
        !           118:   true,
        !           119:   false,
        !           120:   TRUE,
        !           121:   FALSE,
        !           122: 
        !           123:   /* undefined and unset vars */
        !           124:   @$unset_var, 
        !           125:   @$undefined_var
        !           126: );
        !           127: /* loop through the $not_int_types to see working of 
        !           128:    is_int() on non integer types, expected output: bool(false) */
        !           129: $loop_counter = 1;
        !           130: foreach ($not_int_types as $type ) {
        !           131:    echo "--Iteration $loop_counter--\n"; $loop_counter++;   
        !           132:    var_dump( is_int($type) );
        !           133:    var_dump( is_integer($type) );
        !           134:    var_dump( is_long($type) );
        !           135: }
        !           136: 
        !           137: echo "\n*** Testing error conditions ***\n";
        !           138: //Zero argument
        !           139: var_dump( is_int() );
        !           140: var_dump( is_integer() );
        !           141: var_dump( is_long() );
        !           142: 
        !           143: //arguments more than expected 
        !           144: var_dump( is_int(TRUE, FALSE) );
        !           145: var_dump( is_integer(TRUE, FALSE) );
        !           146: var_dump( is_long(TRUE, FALSE) );
        !           147:  
        !           148: echo "Done\n";
        !           149: ?>
        !           150: --EXPECTF--
        !           151: *** Testing is_int(), is_integer() & is_long()  with valid integer values ***
        !           152: --Iteration 1--
        !           153: bool(true)
        !           154: bool(true)
        !           155: bool(true)
        !           156: --Iteration 2--
        !           157: bool(true)
        !           158: bool(true)
        !           159: bool(true)
        !           160: --Iteration 3--
        !           161: bool(true)
        !           162: bool(true)
        !           163: bool(true)
        !           164: --Iteration 4--
        !           165: bool(true)
        !           166: bool(true)
        !           167: bool(true)
        !           168: --Iteration 5--
        !           169: bool(true)
        !           170: bool(true)
        !           171: bool(true)
        !           172: --Iteration 6--
        !           173: bool(true)
        !           174: bool(true)
        !           175: bool(true)
        !           176: --Iteration 7--
        !           177: bool(true)
        !           178: bool(true)
        !           179: bool(true)
        !           180: --Iteration 8--
        !           181: bool(true)
        !           182: bool(true)
        !           183: bool(true)
        !           184: --Iteration 9--
        !           185: bool(true)
        !           186: bool(true)
        !           187: bool(true)
        !           188: --Iteration 10--
        !           189: bool(true)
        !           190: bool(true)
        !           191: bool(true)
        !           192: --Iteration 11--
        !           193: bool(true)
        !           194: bool(true)
        !           195: bool(true)
        !           196: --Iteration 12--
        !           197: bool(true)
        !           198: bool(true)
        !           199: bool(true)
        !           200: --Iteration 13--
        !           201: bool(true)
        !           202: bool(true)
        !           203: bool(true)
        !           204: --Iteration 14--
        !           205: bool(true)
        !           206: bool(true)
        !           207: bool(true)
        !           208: --Iteration 15--
        !           209: bool(true)
        !           210: bool(true)
        !           211: bool(true)
        !           212: --Iteration 16--
        !           213: bool(true)
        !           214: bool(true)
        !           215: bool(true)
        !           216: --Iteration 17--
        !           217: bool(true)
        !           218: bool(true)
        !           219: bool(true)
        !           220: --Iteration 18--
        !           221: bool(true)
        !           222: bool(true)
        !           223: bool(true)
        !           224: 
        !           225: *** Testing is_int(), is_integer() & is_long() with  non integer values ***
        !           226: --Iteration 1--
        !           227: bool(true)
        !           228: bool(true)
        !           229: bool(true)
        !           230: --Iteration 2--
        !           231: bool(true)
        !           232: bool(true)
        !           233: bool(true)
        !           234: --Iteration 3--
        !           235: bool(true)
        !           236: bool(true)
        !           237: bool(true)
        !           238: --Iteration 4--
        !           239: bool(true)
        !           240: bool(true)
        !           241: bool(true)
        !           242: --Iteration 5--
        !           243: bool(true)
        !           244: bool(true)
        !           245: bool(true)
        !           246: --Iteration 6--
        !           247: bool(true)
        !           248: bool(true)
        !           249: bool(true)
        !           250: --Iteration 7--
        !           251: bool(false)
        !           252: bool(false)
        !           253: bool(false)
        !           254: --Iteration 8--
        !           255: bool(false)
        !           256: bool(false)
        !           257: bool(false)
        !           258: --Iteration 9--
        !           259: bool(false)
        !           260: bool(false)
        !           261: bool(false)
        !           262: --Iteration 10--
        !           263: bool(false)
        !           264: bool(false)
        !           265: bool(false)
        !           266: --Iteration 11--
        !           267: bool(false)
        !           268: bool(false)
        !           269: bool(false)
        !           270: --Iteration 12--
        !           271: bool(false)
        !           272: bool(false)
        !           273: bool(false)
        !           274: --Iteration 13--
        !           275: bool(false)
        !           276: bool(false)
        !           277: bool(false)
        !           278: --Iteration 14--
        !           279: bool(false)
        !           280: bool(false)
        !           281: bool(false)
        !           282: --Iteration 15--
        !           283: bool(false)
        !           284: bool(false)
        !           285: bool(false)
        !           286: --Iteration 16--
        !           287: bool(false)
        !           288: bool(false)
        !           289: bool(false)
        !           290: --Iteration 17--
        !           291: bool(false)
        !           292: bool(false)
        !           293: bool(false)
        !           294: --Iteration 18--
        !           295: bool(false)
        !           296: bool(false)
        !           297: bool(false)
        !           298: --Iteration 19--
        !           299: bool(false)
        !           300: bool(false)
        !           301: bool(false)
        !           302: --Iteration 20--
        !           303: bool(false)
        !           304: bool(false)
        !           305: bool(false)
        !           306: --Iteration 21--
        !           307: bool(false)
        !           308: bool(false)
        !           309: bool(false)
        !           310: --Iteration 22--
        !           311: bool(false)
        !           312: bool(false)
        !           313: bool(false)
        !           314: --Iteration 23--
        !           315: bool(false)
        !           316: bool(false)
        !           317: bool(false)
        !           318: --Iteration 24--
        !           319: bool(false)
        !           320: bool(false)
        !           321: bool(false)
        !           322: --Iteration 25--
        !           323: bool(false)
        !           324: bool(false)
        !           325: bool(false)
        !           326: --Iteration 26--
        !           327: bool(false)
        !           328: bool(false)
        !           329: bool(false)
        !           330: --Iteration 27--
        !           331: bool(false)
        !           332: bool(false)
        !           333: bool(false)
        !           334: --Iteration 28--
        !           335: bool(false)
        !           336: bool(false)
        !           337: bool(false)
        !           338: --Iteration 29--
        !           339: bool(false)
        !           340: bool(false)
        !           341: bool(false)
        !           342: --Iteration 30--
        !           343: bool(false)
        !           344: bool(false)
        !           345: bool(false)
        !           346: --Iteration 31--
        !           347: bool(false)
        !           348: bool(false)
        !           349: bool(false)
        !           350: --Iteration 32--
        !           351: bool(false)
        !           352: bool(false)
        !           353: bool(false)
        !           354: --Iteration 33--
        !           355: bool(false)
        !           356: bool(false)
        !           357: bool(false)
        !           358: --Iteration 34--
        !           359: bool(false)
        !           360: bool(false)
        !           361: bool(false)
        !           362: --Iteration 35--
        !           363: bool(false)
        !           364: bool(false)
        !           365: bool(false)
        !           366: --Iteration 36--
        !           367: bool(false)
        !           368: bool(false)
        !           369: bool(false)
        !           370: --Iteration 37--
        !           371: bool(false)
        !           372: bool(false)
        !           373: bool(false)
        !           374: --Iteration 38--
        !           375: bool(false)
        !           376: bool(false)
        !           377: bool(false)
        !           378: --Iteration 39--
        !           379: bool(false)
        !           380: bool(false)
        !           381: bool(false)
        !           382: --Iteration 40--
        !           383: bool(false)
        !           384: bool(false)
        !           385: bool(false)
        !           386: --Iteration 41--
        !           387: bool(false)
        !           388: bool(false)
        !           389: bool(false)
        !           390: --Iteration 42--
        !           391: bool(false)
        !           392: bool(false)
        !           393: bool(false)
        !           394: --Iteration 43--
        !           395: bool(false)
        !           396: bool(false)
        !           397: bool(false)
        !           398: --Iteration 44--
        !           399: bool(false)
        !           400: bool(false)
        !           401: bool(false)
        !           402: --Iteration 45--
        !           403: bool(false)
        !           404: bool(false)
        !           405: bool(false)
        !           406: --Iteration 46--
        !           407: bool(false)
        !           408: bool(false)
        !           409: bool(false)
        !           410: --Iteration 47--
        !           411: bool(false)
        !           412: bool(false)
        !           413: bool(false)
        !           414: --Iteration 48--
        !           415: bool(false)
        !           416: bool(false)
        !           417: bool(false)
        !           418: --Iteration 49--
        !           419: bool(false)
        !           420: bool(false)
        !           421: bool(false)
        !           422: --Iteration 50--
        !           423: bool(false)
        !           424: bool(false)
        !           425: bool(false)
        !           426: --Iteration 51--
        !           427: bool(false)
        !           428: bool(false)
        !           429: bool(false)
        !           430: --Iteration 52--
        !           431: bool(false)
        !           432: bool(false)
        !           433: bool(false)
        !           434: --Iteration 53--
        !           435: bool(false)
        !           436: bool(false)
        !           437: bool(false)
        !           438: --Iteration 54--
        !           439: bool(false)
        !           440: bool(false)
        !           441: bool(false)
        !           442: 
        !           443: *** Testing error conditions ***
        !           444: 
        !           445: Warning: is_int() expects exactly 1 parameter, 0 given in %s on line %d
        !           446: bool(false)
        !           447: 
        !           448: Warning: is_integer() expects exactly 1 parameter, 0 given in %s on line %d
        !           449: bool(false)
        !           450: 
        !           451: Warning: is_long() expects exactly 1 parameter, 0 given in %s on line %d
        !           452: bool(false)
        !           453: 
        !           454: Warning: is_int() expects exactly 1 parameter, 2 given in %s on line %d
        !           455: bool(false)
        !           456: 
        !           457: Warning: is_integer() expects exactly 1 parameter, 2 given in %s on line %d
        !           458: bool(false)
        !           459: 
        !           460: Warning: is_long() expects exactly 1 parameter, 2 given in %s on line %d
        !           461: bool(false)
        !           462: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>