tpi.pp 589 B

12345678910111213141516171819202122232425262728293031
  1. { this tests the pi routine, as an inline }
  2. program tpi;
  3. const
  4. PI_CONST = 3.1459;
  5. { the following expression also works on constants }
  6. PI_CONST_VALUE = pi;
  7. procedure fail;
  8. begin
  9. WriteLn('Failed!');
  10. halt(1);
  11. end;
  12. var
  13. value : real;
  14. _result : boolean;
  15. Begin
  16. Write('Pi() test...');
  17. _result := true;
  18. value:=pi;
  19. if trunc(value) <> trunc(PI_CONST) then
  20. _result := false;
  21. If trunc(Pi) <> trunc(PI_CONST) then
  22. _result := false;
  23. If trunc(Pi) <> trunc(PI_CONST_VALUE) then
  24. _result := false;
  25. if not _result then
  26. fail;
  27. WriteLn('Success!');
  28. end.