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

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