cos_basic.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --TEST--
  2. Test return type and value for expected input cos()
  3. --INI--
  4. precision = 14
  5. --FILE--
  6. <?php
  7. /*
  8. * proto float cos(float number)
  9. * Function is implemented in ext/standard/math.c
  10. */
  11. $file_path = dirname(__FILE__);
  12. require($file_path."/allowed_rounding_error.inc");
  13. // Use known values to test
  14. $sixty = M_PI / 3.0;
  15. $thirty = M_PI / 6.0;
  16. $ninety = M_PI /2.0;
  17. $oneeighty = M_PI;
  18. $twoseventy = M_PI * 1.5;
  19. $threesixty = M_PI * 2.0;
  20. echo "cos 30 = ";
  21. var_dump(cos($thirty));
  22. if (allowed_rounding_error(cos($thirty),0.86602540378444)) {
  23. echo "Pass\n";
  24. }
  25. else {
  26. echo "Fail\n";
  27. }
  28. echo "cos 60 = ";
  29. var_dump(cos($sixty));
  30. if (allowed_rounding_error(cos($sixty),0.5)) {
  31. echo "Pass\n";
  32. }
  33. else {
  34. echo "Fail\n";
  35. }
  36. echo "cos 90 = ";
  37. var_dump(cos($ninety));
  38. if (allowed_rounding_error(cos($ninety),0.0)) {
  39. echo "Pass\n";
  40. }
  41. else {
  42. echo "Fail\n";
  43. }
  44. echo "cos 180 = ";
  45. var_dump(cos($oneeighty));
  46. if (allowed_rounding_error(cos($oneeighty),-1.0)) {
  47. echo "Pass\n";
  48. }
  49. else {
  50. echo "Fail\n";
  51. }
  52. echo "cos 270 = ";
  53. var_dump(cos($twoseventy));
  54. if (allowed_rounding_error(cos($twoseventy),0.0)) {
  55. echo "Pass\n";
  56. }
  57. else {
  58. echo "Fail\n";
  59. }
  60. echo "cos 360 = ";
  61. var_dump(cos($threesixty));
  62. if (allowed_rounding_error(cos($threesixty),1.0)) {
  63. echo "Pass\n";
  64. }
  65. else {
  66. echo "Fail\n";
  67. }
  68. ?>
  69. --EXPECTF--
  70. cos 30 = float(%f)
  71. Pass
  72. cos 60 = float(%f)
  73. Pass
  74. cos 90 = float(%f)
  75. Pass
  76. cos 180 = float(%f)
  77. Pass
  78. cos 270 = float(%f)
  79. Pass
  80. cos 360 = float(%f)
  81. Pass