/test/lib/numeric/real/test_double4.e

http://github.com/tybor/Liberty · Specman e · 90 lines · 63 code · 5 blank · 22 comment · 1 complexity · 7fac1bc53c572119973b26888f959e72 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_DOUBLE4
  5. create {}
  6. make
  7. feature {ANY}
  8. make
  9. local
  10. d: REAL_64; i: INTEGER; r: REAL_32
  11. do
  12. i := 2
  13. assert(i.sign = 1)
  14. i := -2
  15. assert(i.sign = -1)
  16. assert(0.sign = 0)
  17. r := 2
  18. assert(r.sign = 1)
  19. r := -2
  20. assert(r.sign = -1)
  21. assert(0.0.sign = 0)
  22. d := 2
  23. assert(d.sign = 1)
  24. d := -2
  25. assert(d.sign = -1)
  26. d := 0
  27. assert(d.sign = 0)
  28. d := 3.5
  29. assert(d.floor = 3)
  30. assert(d.ceiling = 4)
  31. d := -3.5
  32. assert(d.floor = -4)
  33. assert(d.ceiling = -3)
  34. d := 2.0
  35. assert(d.floor = 2)
  36. assert(d.ceiling = 2)
  37. assert(0.4.rounded.force_to_integer_32 = 0)
  38. assert(0.51.rounded.force_to_integer_32 = 1)
  39. assert(1.49.rounded.force_to_integer_32 = 1)
  40. assert(1.51.rounded.force_to_integer_32 = 2)
  41. assert((-0.4).rounded.force_to_integer_32 = 0)
  42. assert((-0.51).rounded.force_to_integer_32 = -1)
  43. assert((-1.49).rounded.force_to_integer_32 = -1)
  44. assert((-1.51).rounded.force_to_integer_32 = -2)
  45. assert(0.4.rounded = 0)
  46. assert(0.51.rounded = 1)
  47. assert(1.49.rounded = 1)
  48. assert(1.51.rounded = 2)
  49. assert((-0.4).rounded = 0)
  50. assert((-0.51).rounded = -1)
  51. assert((-1.49).rounded = -1)
  52. assert((-1.51).rounded = -2)
  53. end
  54. assert (b: BOOLEAN)
  55. do
  56. cpt := cpt + 1
  57. if not b then
  58. sedb_breakpoint
  59. std_output.put_string("TEST_DOUBLE4: ERROR Test # ")
  60. std_output.put_integer(cpt)
  61. std_output.put_string("%N")
  62. else
  63. -- std_output.put_string("Yes%N");
  64. end
  65. end
  66. cpt: INTEGER
  67. end -- class TEST_DOUBLE4
  68. --
  69. -- ------------------------------------------------------------------------------------------------------------------------------
  70. -- Copyright notice below. Please read.
  71. --
  72. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  73. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  74. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  75. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  76. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  77. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  78. --
  79. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  80. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  81. --
  82. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  83. --
  84. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  85. -- ------------------------------------------------------------------------------------------------------------------------------