Annotation of embedaddon/php/ext/standard/tests/general_functions/var_export_basic1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test var_export() function with integer values
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : mixed var_export(mixed var [, bool return])
! 6: * Description: Outputs or returns a string representation of a variable
! 7: * Source code: ext/standard/var.c
! 8: * Alias to functions:
! 9: */
! 10:
! 11: echo "*** Testing var_export() with integer values ***\n";
! 12: // different integer vlaues
! 13: $valid_ints = array(
! 14: '0' => '0',
! 15: '1' => '1',
! 16: '-1' => '-1',
! 17: '-2147483648' => '-2147483648', // max negative integer value
! 18: '-2147483647' => '-2147483647',
! 19: '2147483647' => 2147483647, // max positive integer value
! 20: '2147483640' => 2147483640,
! 21: '0x123B' => 0x123B, // integer as hexadecimal
! 22: "'0x12ab'" => '0x12ab',
! 23: "'0Xfff'" => '0Xfff',
! 24: "'0XFA'" => '0XFA',
! 25: "-0x80000000" => -0x80000000, // max negative integer as hexadecimal
! 26: "'0x7fffffff'" => '0x7fffffff', // max postive integer as hexadecimal
! 27: "0x7FFFFFFF" => 0x7FFFFFFF, // max postive integer as hexadecimal
! 28: "'0123'" => '0123', // integer as octal
! 29: "01912" => 01912, // should be quivalent to octal 1
! 30: "-020000000000" => -020000000000, // max negative integer as octal
! 31: "017777777777" => 017777777777, // max positive integer as octal
! 32: );
! 33:
! 34: /* Loop to check for above integer values with var_export() */
! 35: echo "\n*** Output for integer values ***\n";
! 36: foreach($valid_ints as $key => $int_value) {
! 37: echo "\n-- Iteration: $key --\n";
! 38: var_export( $int_value );
! 39: echo "\n";
! 40: var_export( $int_value, FALSE);
! 41: echo "\n";
! 42: var_dump( var_export( $int_value, TRUE) );
! 43: }
! 44:
! 45: ?>
! 46: ===DONE===
! 47: --EXPECT--
! 48: *** Testing var_export() with integer values ***
! 49:
! 50: *** Output for integer values ***
! 51:
! 52: -- Iteration: 0 --
! 53: '0'
! 54: '0'
! 55: string(3) "'0'"
! 56:
! 57: -- Iteration: 1 --
! 58: '1'
! 59: '1'
! 60: string(3) "'1'"
! 61:
! 62: -- Iteration: -1 --
! 63: '-1'
! 64: '-1'
! 65: string(4) "'-1'"
! 66:
! 67: -- Iteration: -2147483648 --
! 68: '-2147483648'
! 69: '-2147483648'
! 70: string(13) "'-2147483648'"
! 71:
! 72: -- Iteration: -2147483647 --
! 73: '-2147483647'
! 74: '-2147483647'
! 75: string(13) "'-2147483647'"
! 76:
! 77: -- Iteration: 2147483647 --
! 78: 2147483647
! 79: 2147483647
! 80: string(10) "2147483647"
! 81:
! 82: -- Iteration: 2147483640 --
! 83: 2147483640
! 84: 2147483640
! 85: string(10) "2147483640"
! 86:
! 87: -- Iteration: 0x123B --
! 88: 4667
! 89: 4667
! 90: string(4) "4667"
! 91:
! 92: -- Iteration: '0x12ab' --
! 93: '0x12ab'
! 94: '0x12ab'
! 95: string(8) "'0x12ab'"
! 96:
! 97: -- Iteration: '0Xfff' --
! 98: '0Xfff'
! 99: '0Xfff'
! 100: string(7) "'0Xfff'"
! 101:
! 102: -- Iteration: '0XFA' --
! 103: '0XFA'
! 104: '0XFA'
! 105: string(6) "'0XFA'"
! 106:
! 107: -- Iteration: -0x80000000 --
! 108: -2147483648
! 109: -2147483648
! 110: string(11) "-2147483648"
! 111:
! 112: -- Iteration: '0x7fffffff' --
! 113: '0x7fffffff'
! 114: '0x7fffffff'
! 115: string(12) "'0x7fffffff'"
! 116:
! 117: -- Iteration: 0x7FFFFFFF --
! 118: 2147483647
! 119: 2147483647
! 120: string(10) "2147483647"
! 121:
! 122: -- Iteration: '0123' --
! 123: '0123'
! 124: '0123'
! 125: string(6) "'0123'"
! 126:
! 127: -- Iteration: 01912 --
! 128: 1
! 129: 1
! 130: string(1) "1"
! 131:
! 132: -- Iteration: -020000000000 --
! 133: -2147483648
! 134: -2147483648
! 135: string(11) "-2147483648"
! 136:
! 137: -- Iteration: 017777777777 --
! 138: 2147483647
! 139: 2147483647
! 140: string(10) "2147483647"
! 141: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>