/test/lib/numeric/integer/test_integer4.e

http://github.com/tybor/Liberty · Specman e · 136 lines · 107 code · 5 blank · 24 comment · 1 complexity · 1502c9839455a6458eb1fe234123b06e 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_INTEGER4
  5. create {}
  6. make
  7. feature {ANY}
  8. make
  9. local
  10. a32, b32: INTEGER_32; a64, b64: INTEGER_64
  11. do
  12. a32 := 0xFFFFF000
  13. b32 := a32.bit_shift_right(4)
  14. assert(b32 = 0xFFFFFF00)
  15. a32 := 0xFFFFF000
  16. b32 := a32.bit_shift_right(8)
  17. assert(b32 = 0xFFFFFFF0)
  18. a32 := 0xFFFFF000
  19. b32 := a32.bit_shift_right(12)
  20. assert(b32 = 0xFFFFFFFF)
  21. a32 := 0xFFFFF000
  22. b32 := a32.bit_shift_right(16)
  23. assert(b32 = 0xFFFFFFFF)
  24. a64 := 0xFFFFF000FFFFF000
  25. b64 := a64.bit_shift_right(4)
  26. assert(b64 = 0xFFFFFF000FFFFF00)
  27. a64 := 0xFFFFF000FFFFF000
  28. b64 := a64.bit_shift_right(8)
  29. assert(b64 = 0xFFFFFFF000FFFFF0)
  30. a64 := 0xFFFFF000FFFFF000
  31. b64 := a64.bit_shift_right(12)
  32. assert(b64 = 0xFFFFFFFF000FFFFF)
  33. a64 := 0xFFFFF000FFFFF000
  34. b64 := a64.bit_shift_right(16)
  35. assert(b64 = 0xFFFFFFFFF000FFFF)
  36. a64 := 0xFFFFF000FFFFF000
  37. b64 := a64.bit_shift_right(24)
  38. assert(b64 = 0xFFFFFFFFFFF000FF)
  39. a64 := 0xFFFFF000FFFFF000
  40. b64 := a64.bit_shift_right(32)
  41. assert(b64 = 0xFFFFFFFFFFFFF000)
  42. -- -----------------------------------------------------
  43. a32 := 0x7FFFF000
  44. b32 := a32.bit_shift_right(4)
  45. assert(b32 = 0x07FFFF00)
  46. a32 := 0x7FFFF000
  47. b32 := a32.bit_shift_right(8)
  48. assert(b32 = 0x007FFFF0)
  49. a32 := 0x7FFFF000
  50. b32 := a32.bit_shift_right(12)
  51. assert(b32 = 0x0007FFFF)
  52. a32 := 0x7FFFF000
  53. b32 := a32.bit_shift_right(16)
  54. assert(b32 = 0x00007FFF)
  55. a64 := 0x7FFFF000FFFFF000
  56. b64 := a64.bit_shift_right(4)
  57. assert(b64 = 0x07FFFF000FFFFF00)
  58. a64 := 0x7FFFF000FFFFF000
  59. b64 := a64.bit_shift_right(8)
  60. assert(b64 = 0x007FFFF000FFFFF0)
  61. a64 := 0x7FFFF000FFFFF000
  62. b64 := a64.bit_shift_right(12)
  63. assert(b64 = 0x0007FFFF000FFFFF)
  64. a64 := 0x7FFFF000FFFFF000
  65. b64 := a64.bit_shift_right(16)
  66. assert(b64 = 0x00007FFFF000FFFF)
  67. a64 := 0x7FFFF000FFFFF000
  68. b64 := a64.bit_shift_right(24)
  69. assert(b64 = 0x0000007FFFF000FF)
  70. a64 := 0x7FFFF000FFFFF000
  71. b64 := a64.bit_shift_right(32)
  72. assert(b64 = 0x000000007FFFF000)
  73. -- -----------------------------------------------------
  74. a32 := 0xFFFFF000
  75. assert(a32.bit_not = 0x00000FFF)
  76. b32 := a32.bit_shift_right_unsigned(4)
  77. assert(b32 = 0x0FFFFF00)
  78. a32 := 0xFFFFF000
  79. b32 := a32.bit_shift_right_unsigned(8)
  80. assert(b32 = 0x00FFFFF0)
  81. a32 := 0xFFFFF000
  82. b32 := a32.bit_shift_right_unsigned(12)
  83. assert(b32 = 0x000FFFFF)
  84. a32 := 0xFFFFF000
  85. b32 := a32.bit_shift_right_unsigned(16)
  86. assert(b32 = 0x0000FFFF)
  87. a64 := 0xFFFFF000FFFFF000
  88. sedb_breakpoint
  89. b64 := a64.bit_shift_right_unsigned(8)
  90. assert(b64 = 0x00FFFFF000FFFFF0)
  91. a64 := 0xFFFFF000FFFFF000
  92. b64 := a64.bit_shift_right_unsigned(16)
  93. assert(b64 = 0x0000FFFFF000FFFF)
  94. a64 := 0xFFFFF000FFFFF000
  95. b64 := a64.bit_shift_right_unsigned(24)
  96. assert(b64 = 0x000000FFFFF000FF)
  97. a64 := 0xFFFFF000FFFFF000
  98. b64 := a64.bit_shift_right_unsigned(32)
  99. assert(b64 = 0x00000000FFFFF000)
  100. -- -----------------------------------------------------
  101. end
  102. assert (b: BOOLEAN)
  103. do
  104. cpt := cpt + 1
  105. if not b then
  106. sedb_breakpoint
  107. std_output.put_string("TEST_INTEGER4: ERROR Test # ")
  108. std_output.put_integer(cpt)
  109. std_output.put_string("%N")
  110. end
  111. end
  112. cpt: INTEGER
  113. end -- class TEST_INTEGER4
  114. --
  115. -- ------------------------------------------------------------------------------------------------------------------------------
  116. -- Copyright notice below. Please read.
  117. --
  118. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  119. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  120. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  121. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  122. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  123. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  124. --
  125. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  126. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  127. --
  128. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  129. --
  130. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  131. -- ------------------------------------------------------------------------------------------------------------------------------