/test/lib/numeric/real/test_is_zero.e

http://github.com/tybor/Liberty · Specman e · 81 lines · 49 code · 8 blank · 24 comment · 0 complexity · ed6b2b820dd54ff9236fade2317b2429 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_IS_ZERO
  5. --
  6. -- Of REAL_GENERAL.
  7. --
  8. insert
  9. EIFFELTEST_TOOLS
  10. create {}
  11. make
  12. feature {ANY}
  13. make
  14. local
  15. real_32: REAL_32; real_64: REAL_64; real_extended: REAL_EXTENDED
  16. do
  17. assert(real_64.is_zero)
  18. real_64 := -real_64
  19. assert(real_64.is_zero)
  20. assert(infinity_64.is_infinity)
  21. real_64 := 2.0 / infinity_64
  22. assert(real_64.is_zero)
  23. assert(real_32.is_zero)
  24. real_32 := -real_32
  25. assert(real_32.is_zero)
  26. assert(infinity_32.is_infinity)
  27. real_32 := {REAL_32 2.0} / infinity_32
  28. assert(real_32.is_zero)
  29. assert(real_extended.is_zero)
  30. real_extended := -real_extended
  31. assert(real_extended.is_zero)
  32. assert(infinity_extended.is_infinity)
  33. real_extended := {REAL_EXTENDED 2.0} / infinity_extended
  34. assert(real_extended.is_zero)
  35. end
  36. infinity_64: REAL_64
  37. do
  38. Result := infinity_32
  39. end
  40. infinity_32: REAL_32
  41. local
  42. x, y: REAL_32
  43. do
  44. x := {REAL_32 1.0}
  45. Result := unchecked_c_divide(x, y)
  46. end
  47. infinity_extended: REAL_EXTENDED
  48. do
  49. Result := infinity_32
  50. end
  51. unchecked_c_divide (x, y: REAL_32): REAL_32
  52. external "C inline"
  53. alias "($x/$y)"
  54. end
  55. end -- class TEST_IS_ZERO
  56. --
  57. -- ------------------------------------------------------------------------------------------------------------------------------
  58. -- Copyright notice below. Please read.
  59. --
  60. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  61. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  62. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  63. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  64. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  65. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  66. --
  67. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  68. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  69. --
  70. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  71. --
  72. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  73. -- ------------------------------------------------------------------------------------------------------------------------------