/test/lib/numeric/number/test_number12.e

http://github.com/tybor/Liberty · Specman e · 74 lines · 40 code · 6 blank · 28 comment · 0 complexity · 8d4fa44527110c546821b8737c904434 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_NUMBER12
  5. -- tests between large numbers and integer numbers
  6. insert
  7. EIFFELTEST_TOOLS
  8. PLATFORM
  9. NUMBER_TOOLS
  10. create {}
  11. make
  12. feature {ANY}
  13. make
  14. local
  15. n1, n2: NUMBER
  16. do
  17. n1 := from_integer(Maximum_integer)
  18. n1 := n1 @+ 1000
  19. n2 := from_integer(Minimum_integer)
  20. n2 := n2 @- 1000
  21. -- is_zero
  22. assert(not n1.is_zero)
  23. assert(not n2.is_zero)
  24. -- is_positive
  25. assert(n1.is_positive)
  26. assert(not n2.is_positive)
  27. -- is_negative
  28. assert(not n1.is_negative)
  29. assert(n2.is_negative)
  30. -- odd
  31. assert(n1.is_odd)
  32. assert(not n2.is_odd)
  33. -- even
  34. assert(not n1.is_even)
  35. assert(n2.is_even)
  36. -- operations
  37. assert((n1 / n1) @= 1)
  38. assert((n1 @/ 1).is_equal(n1))
  39. assert((n1 @// 1).is_equal(n1))
  40. assert(n1 @\\ 1 @= 0)
  41. assert(n1.sign = 1)
  42. assert(n2.sign = -1)
  43. assert(n1.log > 0)
  44. assert((n2 @+ 1).abs.is_equal(n1.abs))
  45. assert(n1.compare(n2) = 1)
  46. assert(n2.compare(n1) = -1)
  47. assert(n1.min(n2).is_equal(n2))
  48. assert(n1.max(n2).is_equal(n1))
  49. end
  50. end -- class TEST_NUMBER12
  51. --
  52. -- ------------------------------------------------------------------------------------------------------------------------------
  53. -- Copyright notice below. Please read.
  54. --
  55. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  56. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  57. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  58. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  59. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  60. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  61. --
  62. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  63. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  64. --
  65. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  66. --
  67. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  68. -- ------------------------------------------------------------------------------------------------------------------------------