/test/lib/numeric/real/test_double1.e

http://github.com/tybor/Liberty · Specman e · 71 lines · 44 code · 5 blank · 22 comment · 1 complexity · d53b6a397b7f3558113cd162ae95d713 MD5 · raw file

  1. -- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
  2. -- See the Copyright notice at the end of this file.
  3. --
  4. class TEST_DOUBLE1
  5. create {}
  6. make
  7. feature {ANY}
  8. make
  9. local
  10. i: INTEGER; d, d2: REAL_64
  11. do
  12. d := 1.6
  13. assert(d = d)
  14. assert(d >= 1.59)
  15. assert(d <= 1.61)
  16. d := 2
  17. assert(d = 2.0)
  18. i := 2
  19. d := i
  20. assert(d = 2)
  21. assert(d = 2.0)
  22. d := 1.51.to_string.to_real
  23. assert(d < 1.511)
  24. assert(d > 1.509)
  25. d := (-1.51).to_string.to_real
  26. assert(d > -1.52)
  27. assert(d < -1.50)
  28. assert(d.abs < 1.52)
  29. assert(d.abs > 1.50)
  30. assert((-d).abs < 1.52)
  31. assert((-d).abs > 1.50)
  32. d := 4.0
  33. d2 := 2.0
  34. assert(d.sqrt = d2)
  35. end
  36. assert (b: BOOLEAN)
  37. do
  38. cpt := cpt + 1
  39. if not b then
  40. std_output.put_string("TEST_DOUBLE1: ERROR Test # ")
  41. std_output.put_integer(cpt)
  42. std_output.put_string("%N")
  43. else
  44. -- std_output.put_string("Yes%N");
  45. end
  46. end
  47. cpt: INTEGER
  48. end -- class TEST_DOUBLE1
  49. --
  50. -- ------------------------------------------------------------------------------------------------------------------------------
  51. -- Copyright notice below. Please read.
  52. --
  53. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  54. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  55. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  56. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  57. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  58. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  59. --
  60. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  61. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  62. --
  63. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  64. --
  65. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  66. -- ------------------------------------------------------------------------------------------------------------------------------