sin_basic.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --TEST--
  2. Test return type and value for expected input sin()
  3. --INI--
  4. precision = 14
  5. --FILE--
  6. <?php
  7. /*
  8. * proto float sin(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 "sin 30 = ";
  21. var_dump(sin($thirty));
  22. if (allowed_rounding_error(sin($thirty),0.5)) {
  23. echo "Pass\n";
  24. }
  25. else {
  26. echo "Fail\n";
  27. }
  28. echo "sin 60 = ";
  29. var_dump(sin($sixty));
  30. if (allowed_rounding_error(sin($sixty),0.86602540378444)) {
  31. echo "Pass\n";
  32. }
  33. else {
  34. echo "Fail\n";
  35. }
  36. echo "sin 90 = ";
  37. var_dump(sin($ninety));
  38. if (allowed_rounding_error(sin($ninety),1.0)) {
  39. echo "Pass\n";
  40. }
  41. else {
  42. echo "Fail\n";
  43. }
  44. echo "sin 180 = ";
  45. var_dump(sin($oneeighty));
  46. if (allowed_rounding_error(sin($oneeighty),0.0)) {
  47. echo "Pass\n";
  48. }
  49. else {
  50. echo "Fail\n";
  51. }
  52. echo "sin 270 = ";
  53. var_dump(sin($twoseventy));
  54. if (allowed_rounding_error(sin($twoseventy),-1.0)) {
  55. echo "Pass\n";
  56. }
  57. else {
  58. echo "Fail\n";
  59. }
  60. echo "sin 360 = ";
  61. var_dump(sin($threesixty));
  62. if (allowed_rounding_error(sin($threesixty),0.0)) {
  63. echo "Pass\n";
  64. }
  65. else {
  66. echo "Fail\n";
  67. }
  68. ?>
  69. --EXPECTF--
  70. sin 30 = float(%f)
  71. Pass
  72. sin 60 = float(%f)
  73. Pass
  74. sin 90 = float(%f)
  75. Pass
  76. sin 180 = float(%f)
  77. Pass
  78. sin 270 = float(%f)
  79. Pass
  80. sin 360 = float(%f)
  81. Pass