array_values_variation.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --TEST--
  2. Test array_values() function (variation)
  3. --SKIPIF--
  4. <?php
  5. if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
  6. ?>
  7. --INI--
  8. precision=14
  9. --FILE--
  10. <?php
  11. echo "\n*** Testing array_values() with resource type ***\n";
  12. $resource1 = fopen(__FILE__, "r"); // Creating a file resource
  13. $resource2 = opendir("."); // Creating a dir resource
  14. /* creating an array with resources as elements */
  15. $arr_resource = array( "a" => $resource1, "b" => $resource2);
  16. var_dump( array_values($arr_resource) );
  17. echo "\n*** Testing array_values() with range checking ***\n";
  18. $arr_range = array(
  19. 2147483647,
  20. 2147483648,
  21. -2147483647,
  22. -2147483648,
  23. -0,
  24. 0,
  25. -2147483649
  26. );
  27. var_dump( array_values($arr_range) );
  28. echo "\n*** Testing array_values() on an array created on the fly ***\n";
  29. var_dump( array_values(array(1,2,3)) );
  30. var_dump( array_values(array()) ); // null array
  31. echo "Done\n";
  32. ?>
  33. --EXPECTF--
  34. *** Testing array_values() with resource type ***
  35. array(2) {
  36. [0]=>
  37. resource(%d) of type (stream)
  38. [1]=>
  39. resource(%d) of type (stream)
  40. }
  41. *** Testing array_values() with range checking ***
  42. array(7) {
  43. [0]=>
  44. int(2147483647)
  45. [1]=>
  46. float(2147483648)
  47. [2]=>
  48. int(-2147483647)
  49. [3]=>
  50. float(-2147483648)
  51. [4]=>
  52. int(0)
  53. [5]=>
  54. int(0)
  55. [6]=>
  56. float(-2147483649)
  57. }
  58. *** Testing array_values() on an array created on the fly ***
  59. array(3) {
  60. [0]=>
  61. int(1)
  62. [1]=>
  63. int(2)
  64. [2]=>
  65. int(3)
  66. }
  67. array(0) {
  68. }
  69. Done