max.phpt 850 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. max() tests
  3. --INI--
  4. precision=14
  5. --FILE--
  6. <?php
  7. try {
  8. var_dump(max(1));
  9. } catch (\TypeError $e) {
  10. echo $e->getMessage() . "\n";
  11. }
  12. try {
  13. var_dump(max(array()));
  14. } catch (\ValueError $e) {
  15. echo $e->getMessage() . "\n";
  16. }
  17. try {
  18. var_dump(max(new stdclass));
  19. } catch (\TypeError $e) {
  20. echo $e->getMessage() . "\n";
  21. }
  22. var_dump(max(2,1,2));
  23. var_dump(max(2.1,2.11,2.09));
  24. var_dump(max("", "t", "b"));
  25. var_dump(max(false, true, false));
  26. var_dump(max(true, false, true));
  27. var_dump(max(1, true, false, true));
  28. var_dump(max(0, true, false, true));
  29. ?>
  30. --EXPECT--
  31. max(): Argument #1 ($value) must be of type array, int given
  32. max(): Argument #1 ($value) must contain at least one element
  33. max(): Argument #1 ($value) must be of type array, stdClass given
  34. int(2)
  35. float(2.11)
  36. string(1) "t"
  37. bool(true)
  38. bool(true)
  39. int(1)
  40. bool(true)