/test/lib/numeric/number/test_number107.e

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