/test/lib/numeric/natural/test_natural1.e

http://github.com/tybor/Liberty · Specman e · 142 lines · 100 code · 20 blank · 22 comment · 0 complexity · e9454ec06f4283854f5a0dc239181e9f 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_NATURAL1
  5. inherit
  6. EIFFELTEST_TOOLS
  7. create {}
  8. main
  9. feature {}
  10. main
  11. local
  12. a8, b8, c8, d8, e8, f8, g8, h8, j8: NATURAL_8
  13. a64, b64, c64, d64, e64, f64, g64, h64, j64: NATURAL_64
  14. do
  15. assert(j8 = 0.to_natural_8)
  16. a8 := a8 + 1.to_natural_8
  17. assert(a8 /= 0.to_natural_8)
  18. assert(a8 = 1.to_natural_8)
  19. b8 := 2.to_natural_8
  20. c8 := 100.to_natural_8
  21. assert(b8 = b8)
  22. assert(a8 + a8 = b8)
  23. assert(a8 < b8)
  24. assert(a8 <= b8)
  25. assert(b8 >= b8)
  26. assert(b8 >= a8)
  27. assert(b8 > a8)
  28. assert(c8 > b8)
  29. assert(c8 = c8)
  30. e8 := c8
  31. d8 := c8 + e8
  32. assert(d8 > c8)
  33. assert(d8 >= e8)
  34. assert(d8 >= e8 + c8)
  35. assert(d8 <= e8 + c8)
  36. assert(a8 = a8)
  37. assert(not (a8 = j8))
  38. assert(not (j8 = a8))
  39. assert(j8 < a8)
  40. assert(not (a8 < j8))
  41. assert(j8 <= a8)
  42. assert(a8 > j8)
  43. assert(a8 >= j8)
  44. h8 := 10.to_natural_8
  45. g8 := c8 // h8
  46. f8 := c8 \\ h8
  47. assert(g8 = h8)
  48. assert(f8 = (a8 - a8))
  49. assert((a8 + b8).to_integer_32 = 3)
  50. assert(a8.out.is_equal("1"))
  51. assert(b8.out.is_equal("2"))
  52. assert(d8.out.is_equal("200"))
  53. -- ----------------------------------------
  54. assert(j64 = 0.to_natural_64)
  55. a64 := a64 + 1.to_natural_64
  56. assert(a64 /= 0.to_natural_64)
  57. assert(a64 = 1.to_natural_64)
  58. b64 := 2.to_natural_64
  59. c64 := 100.to_natural_64
  60. assert(b64 = b64)
  61. assert(a64 + a64 = b64)
  62. assert(a64 < b64)
  63. assert(a64 <= b64)
  64. assert(b64 >= b64)
  65. assert(b64 >= a64)
  66. assert(b64 > a64)
  67. assert(c64 > b64)
  68. assert(c64 = c64)
  69. e64 := c64
  70. d64 := c64 + e64
  71. assert(d64 > c64)
  72. assert(d64 >= e64)
  73. assert(d64 >= e64 + c64)
  74. assert(d64 <= e64 + c64)
  75. assert(a64 = a64)
  76. assert(not (a64 = j64))
  77. assert(not (j64 = a64))
  78. assert(j64 < a64)
  79. assert(not (a64 < j64))
  80. assert(j64 <= a64)
  81. assert(a64 > j64)
  82. assert(a64 >= j64)
  83. h64 := 10.to_natural_64
  84. g64 := c64 // h64
  85. f64 := c64 \\ h64
  86. assert(g64 = h64)
  87. assert(f64 = (a64 - a64))
  88. assert((a64 + b64).to_integer_32 = 3)
  89. assert(a64.out.is_equal("1"))
  90. assert(a64.to_number.to_string.is_equal("1"))
  91. assert(b64.out.is_equal("2"))
  92. assert(d64.out.is_equal("200"))
  93. d64 := 9223372036854775807.to_natural_64
  94. assert(d64.out.is_equal("9223372036854775807"))
  95. d64 := d64 * 2.to_natural_64
  96. assert(d64.out.is_equal("18446744073709551614"))
  97. assert(d64.to_number.to_string.is_equal("18446744073709551614"))
  98. d64 := d64 + 1.to_natural_64
  99. assert(d64.out.is_equal("18446744073709551615"))
  100. assert(d64.to_number.to_string.is_equal("18446744073709551615"))
  101. d64 := d64 #+ 1.to_natural_64
  102. assert(d64.out.is_equal("0"))
  103. end
  104. end -- class TEST_NATURAL1
  105. --
  106. -- ------------------------------------------------------------------------------------------------------------------------------
  107. -- Copyright notice below. Please read.
  108. --
  109. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  110. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  111. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  112. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  113. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  114. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  115. --
  116. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  117. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  118. --
  119. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  120. --
  121. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  122. -- ------------------------------------------------------------------------------------------------------------------------------