PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 94 lines | 56 code | 18 blank | 20 comment | 0 complexity | df67732b907250304f8135c8e479c8e9 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. $im = imagecreatetruecolor(200, 200);
  8. $red = 10;
  9. $green = 10;
  10. $fp = tmpfile();
  11. //get an unset variable
  12. $unset_var = 10;
  13. unset ($unset_var);
  14. // define some classes
  15. class classWithToString
  16. {
  17. public function __toString() {
  18. return "Class A object";
  19. }
  20. }
  21. class classWithoutToString
  22. {
  23. }
  24. // heredoc string
  25. $heredoc = <<<EOT
  26. hello world
  27. EOT;
  28. // add arrays
  29. $index_array = array (1, 2, 3);
  30. $assoc_array = array ('one' => 1, 'two' => 2);
  31. //array of values to iterate over
  32. $values = array(
  33. // float data
  34. 'float 10.5' => 10.5,
  35. 'float -10.5' => -10.5,
  36. 'float 10.1234567e10' => 10.1234567e10,
  37. 'float 10.7654321E-10' => 10.7654321E-10,
  38. 'float .5' => .5,
  39. // array data
  40. 'empty array' => array(),
  41. 'int indexed array' => $index_array,
  42. 'associative array' => $assoc_array,
  43. 'nested arrays' => array('foo', $index_array, $assoc_array),
  44. // null data
  45. 'uppercase NULL' => NULL,
  46. 'lowercase null' => null,
  47. // boolean data
  48. 'lowercase true' => true,
  49. 'lowercase false' =>false,
  50. 'uppercase TRUE' =>TRUE,
  51. 'uppercase FALSE' =>FALSE,
  52. // empty data
  53. 'empty string DQ' => "",
  54. 'empty string SQ' => '',
  55. // string data
  56. 'string DQ' => "string",
  57. 'string SQ' => 'string',
  58. 'mixed case string' => "sTrInG",
  59. 'heredoc' => $heredoc,
  60. // object data
  61. 'instance of classWithToString' => new classWithToString(),
  62. 'instance of classWithoutToString' => new classWithoutToString(),
  63. // undefined data
  64. 'undefined var' => @$undefined_var,
  65. // unset data
  66. 'unset var' => @$unset_var,
  67. //resource
  68. "file resource" => $fp
  69. );
  70. // loop through each element of the array for red
  71. foreach($values as $key => $value) {
  72. echo "\n--$key--\n";
  73. var_dump( imagecolorallocate($im, $red, $green, $value) );
  74. };
  75. ?>
  76. ===DONE===