/test/lib/numeric/integer/test_integer6.e

http://github.com/tybor/Liberty · Specman e · 107 lines · 72 code · 5 blank · 30 comment · 1 complexity · c21fabddebba2e9aabfe2d38a61745b7 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_INTEGER6
  5. --
  6. -- Balancing rule implies some weird stuff...
  7. --
  8. create {}
  9. make
  10. feature {ANY}
  11. make
  12. local
  13. a8, b8: INTEGER_8; a16: INTEGER_16; a32: INTEGER_32; a64: INTEGER_64
  14. do
  15. a8 := 0xff
  16. b8 := a8.bit_shift_right(1)
  17. assert(b8 = 0xff)
  18. a8 := 0xff
  19. b8 := a8.bit_shift_right_unsigned(1)
  20. assert(b8 = 0x7f)
  21. -- -----------------------------------------------------
  22. a16 := 0x00ff
  23. a8 := a16.low_8
  24. assert(a8 = 0xff)
  25. a8 := a16.high_8
  26. assert(a8 = 0x00)
  27. a16 := 0xffff
  28. a8 := a16.low_8
  29. assert(a8 = 0xff)
  30. a8 := a16.high_8
  31. assert(a8 = 0xff)
  32. a16 := 0xff7f
  33. a8 := a16.low_8
  34. assert(a8 = 0x7f)
  35. a8 := a16.high_8
  36. assert(a8 = 0xff)
  37. -- -----------------------------------------------------
  38. -- -----------------------------------------------------
  39. a32 := 0x0000ffff
  40. a16 := a32.low_16
  41. assert(a16 = 0xffff)
  42. a16 := a32.high_16
  43. assert(a16 = 0x0000)
  44. a32 := 0xffffffff
  45. a16 := a32.low_16
  46. assert(a16 = 0xffff)
  47. a16 := a32.high_16
  48. assert(a16 = 0xffff)
  49. a32 := 0xffff7fff
  50. a16 := a32.low_16
  51. assert(a16 = 0x7fff)
  52. a16 := a32.high_16
  53. assert(a16 = 0xffff)
  54. -- -----------------------------------------------------
  55. -- -----------------------------------------------------
  56. a64 := 0x00000000ffffffff
  57. a32 := a64.low_32
  58. assert(a32 = 0xffffffff)
  59. a32 := a64.high_32
  60. assert(a32 = 0x00000000)
  61. a64 := 0xffffffffffffffff
  62. a32 := a64.low_32
  63. assert(a32 = 0xffffffff)
  64. a32 := a64.high_32
  65. assert(a32 = 0xffffffff)
  66. a64 := 0xffffffff7fffffff
  67. a32 := a64.low_32
  68. assert(a32 = 0x7fffffff)
  69. a32 := a64.high_32
  70. assert(a32 = 0xffffffff)
  71. -- -----------------------------------------------------
  72. end
  73. assert (b: BOOLEAN)
  74. do
  75. cpt := cpt + 1
  76. if not b then
  77. sedb_breakpoint
  78. std_output.put_string("TEST_INTEGER6: ERROR Test # ")
  79. std_output.put_integer(cpt)
  80. std_output.put_string("%N")
  81. end
  82. end
  83. cpt: INTEGER
  84. end -- class TEST_INTEGER6
  85. --
  86. -- ------------------------------------------------------------------------------------------------------------------------------
  87. -- Copyright notice below. Please read.
  88. --
  89. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  90. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  91. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  92. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  93. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  94. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  95. --
  96. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  97. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  98. --
  99. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  100. --
  101. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  102. -- ------------------------------------------------------------------------------------------------------------------------------