/test/lib/numeric/number/test_number105.e

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