PageRenderTime 56ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/bad/ext/gd/tests/imagecolorallocate_variation1.php

http://github.com/facebook/hiphop-php
PHP | 105 lines | 60 code | 23 blank | 22 comment | 0 complexity | 6f1281ca91cb768ed2828d0284b550ca MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. /* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
  3. * Description: Allocate a color for an image
  4. * Source code: ext/gd/gd.c
  5. */
  6. echo "*** Testing imagecolorallocate() : usage variations ***\n";
  7. // Initialise function arguments not being substituted (if any)
  8. $red = 10;
  9. $green = 10;
  10. $blue = 10;
  11. $fp = tmpfile();
  12. //get an unset variable
  13. $unset_var = 10;
  14. unset ($unset_var);
  15. // define some classes
  16. class classWithToString
  17. {
  18. public function __toString() {
  19. return "Class A object";
  20. }
  21. }
  22. class classWithoutToString
  23. {
  24. }
  25. // heredoc string
  26. $heredoc = <<<EOT
  27. hello world
  28. EOT;
  29. // add arrays
  30. $index_array = array (1, 2, 3);
  31. $assoc_array = array ('one' => 1, 'two' => 2);
  32. //array of values to iterate over
  33. $values = array(
  34. // int data
  35. 'int 0' => 0,
  36. 'int 1' => 1,
  37. 'int 12345' => 12345,
  38. 'int -12345' => -12345,
  39. // float data
  40. 'float 10.5' => 10.5,
  41. 'float -10.5' => -10.5,
  42. 'float 10.1234567e10' => 10.1234567e10,
  43. 'float 10.7654321E-10' => 10.7654321E-10,
  44. 'float .5' => .5,
  45. // array data
  46. 'empty array' => array(),
  47. 'int indexed array' => $index_array,
  48. 'associative array' => $assoc_array,
  49. 'nested arrays' => array('foo', $index_array, $assoc_array),
  50. // null data
  51. 'uppercase NULL' => NULL,
  52. 'lowercase null' => null,
  53. // boolean data
  54. 'lowercase true' => true,
  55. 'lowercase false' =>false,
  56. 'uppercase TRUE' =>TRUE,
  57. 'uppercase FALSE' =>FALSE,
  58. // empty data
  59. 'empty string DQ' => "",
  60. 'empty string SQ' => '',
  61. // string data
  62. 'string DQ' => "string",
  63. 'string SQ' => 'string',
  64. 'mixed case string' => "sTrInG",
  65. 'heredoc' => $heredoc,
  66. // object data
  67. 'instance of classWithToString' => new classWithToString(),
  68. 'instance of classWithoutToString' => new classWithoutToString(),
  69. // undefined data
  70. 'undefined var' => @$undefined_var,
  71. // unset data
  72. 'unset var' => @$unset_var,
  73. //resource
  74. "file resource" => $fp
  75. );
  76. // loop through each element of the array for im
  77. foreach($values as $key => $value) {
  78. echo "\n-- $key --\n";
  79. var_dump( imagecolorallocate($value, $red, $green, $blue) );
  80. };
  81. ?>
  82. ===DONE===