/test/language/simplify/test_simplify21.e

http://github.com/tybor/Liberty · Specman e · 326 lines · 267 code · 28 blank · 31 comment · 51 complexity · 11f69fb399fd6daca9732c6f9d445ade 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_SIMPLIFY21
  5. insert
  6. PLATFORM
  7. EIFFELTEST_TOOLS
  8. create {}
  9. make
  10. feature {}
  11. make
  12. do
  13. -- Testing infix "+":
  14. if -128 + 127 = -1 then
  15. assert(True)
  16. else
  17. c_inline_c("*** WrongCcode #1 in TEST_SIMPLIFY21 ***")
  18. end
  19. if Maximum_integer_8 + Minimum_integer_8 = -1 then
  20. assert(True)
  21. else
  22. c_inline_c("*** WrongCcode #2 in TEST_SIMPLIFY21 ***")
  23. end
  24. if -32768 + 32767 = -1 then
  25. assert(True)
  26. else
  27. c_inline_c("*** WrongCcode #3 in TEST_SIMPLIFY21 ***")
  28. end
  29. if Maximum_integer_16 + Minimum_integer_16 = -1 then
  30. assert(True)
  31. else
  32. c_inline_c("*** WrongCcode #4 in TEST_SIMPLIFY21 ***")
  33. end
  34. if -2147483648 + 2147483647 = -1 then
  35. assert(True)
  36. else
  37. c_inline_c("*** WrongCcode #5 in TEST_SIMPLIFY21 ***")
  38. end
  39. if Maximum_integer_32 + Minimum_integer_32 = -1 then
  40. assert(True)
  41. else
  42. c_inline_c("*** WrongCcode #6 in TEST_SIMPLIFY21 ***")
  43. end
  44. if 9223372036854775807 + Minimum_integer_64 = -1 then
  45. assert(True)
  46. else
  47. c_inline_c("*** WrongCcode #7 in TEST_SIMPLIFY21 ***")
  48. end
  49. if Maximum_integer_64 + Minimum_integer_64 = -1 then
  50. assert(True)
  51. else
  52. c_inline_c("*** WrongCcode #8 in TEST_SIMPLIFY21 ***")
  53. end
  54. -- Testing infix "-":
  55. if 127 - 127 - 127 - 1 = -128 then
  56. assert(True)
  57. else
  58. c_inline_c("*** WrongCcode #9 in TEST_SIMPLIFY21 ***")
  59. end
  60. if Maximum_integer_8 - Maximum_integer_8 = 0 then
  61. assert(True)
  62. else
  63. c_inline_c("*** WrongCcode #10 in TEST_SIMPLIFY21 ***")
  64. end
  65. if 32767 - 32767 - 32767 = - 32767 then
  66. assert(True)
  67. else
  68. c_inline_c("*** WrongCcode #11 in TEST_SIMPLIFY21 ***")
  69. end
  70. if Maximum_integer_16 - Maximum_integer_16 = 0 then
  71. assert(True)
  72. else
  73. c_inline_c("*** WrongCcode #12 in TEST_SIMPLIFY21 ***")
  74. end
  75. if 2147483647 - 2147483647 - 2147483647 = - 2147483647 then
  76. assert(True)
  77. else
  78. c_inline_c("*** WrongCcode #13 in TEST_SIMPLIFY21 ***")
  79. end
  80. if Maximum_integer_32 - Maximum_integer_32 = 0 then
  81. assert(True)
  82. else
  83. c_inline_c("*** WrongCcode #14 in TEST_SIMPLIFY21 ***")
  84. end
  85. if 9223372036854775807 - 9223372036854775807 - 9223372036854775807 = - 9223372036854775807 then
  86. assert(True)
  87. else
  88. c_inline_c("*** WrongCcode #15 in TEST_SIMPLIFY21 ***")
  89. end
  90. if Maximum_integer_64 - Maximum_integer_64 = 0 then
  91. assert(True)
  92. else
  93. c_inline_c("*** WrongCcode #16 in TEST_SIMPLIFY21 ***")
  94. end
  95. -- Testing infix "*":
  96. if 1 * Minimum_integer_8 = -128 then
  97. assert(True)
  98. else
  99. c_inline_c("*** WrongCcode #17 in TEST_SIMPLIFY21 ***")
  100. end
  101. if {INTEGER_16 2} * Minimum_integer_8 = -256 then
  102. assert(True)
  103. else
  104. c_inline_c("*** WrongCcode #18 in TEST_SIMPLIFY21 ***")
  105. end
  106. if {INTEGER_32 2} * Maximum_integer_16 = 65534 then
  107. assert(True)
  108. else
  109. c_inline_c("*** WrongCcode #19 in TEST_SIMPLIFY21 ***")
  110. end
  111. if {INTEGER_64 2} * Maximum_integer_16 * Maximum_integer_16 = 2147352578 then
  112. assert(True)
  113. else
  114. c_inline_c("*** WrongCcode #20 in TEST_SIMPLIFY21 ***")
  115. end
  116. -- Testing {INTEGER_*}.to_character:
  117. if 32.to_character = ' ' then
  118. assert(True)
  119. else
  120. c_inline_c("*** WrongCcode #20 in TEST_SIMPLIFY21 ***")
  121. end
  122. -- Testing {INTEGER_*}.bit_shift_right:
  123. if 2.bit_shift_right(1) = 1 then
  124. assert(True)
  125. else
  126. c_inline_c("*** WrongCcode #21 in TEST_SIMPLIFY21 ***")
  127. end
  128. if 64.bit_shift_right(6) = 1 then
  129. assert(True)
  130. else
  131. c_inline_c("*** WrongCcode #22 in TEST_SIMPLIFY21 ***")
  132. end
  133. if {INTEGER_16 2}.bit_shift_right(1) = 1 then
  134. assert(True)
  135. else
  136. c_inline_c("*** WrongCcode #23 in TEST_SIMPLIFY21 ***")
  137. end
  138. if 16384.bit_shift_right(14) = 1 then
  139. assert(True)
  140. else
  141. c_inline_c("*** WrongCcode #24 in TEST_SIMPLIFY21 ***")
  142. end
  143. if {INTEGER_32 2}.bit_shift_right(1) = 1 then
  144. assert(True)
  145. else
  146. c_inline_c("*** WrongCcode #25 in TEST_SIMPLIFY21 ***")
  147. end
  148. if 1073741824.bit_shift_right(30) = 1 then
  149. assert(True)
  150. else
  151. c_inline_c("*** WrongCcode #26 in TEST_SIMPLIFY21 ***")
  152. end
  153. if {INTEGER_64 2}.bit_shift_right(1) = 1 then
  154. assert(True)
  155. else
  156. c_inline_c("*** WrongCcode #27 in TEST_SIMPLIFY21 ***")
  157. end
  158. if 4611686018427387904.bit_shift_right(62) = 1 then
  159. assert(True)
  160. else
  161. c_inline_c("*** WrongCcode #28 in TEST_SIMPLIFY21 ***")
  162. end
  163. -- Testing {INTEGER_*}.bit_not:
  164. if 0.bit_not = -1 then
  165. assert(True)
  166. else
  167. c_inline_c("*** WrongCcode #29 in TEST_SIMPLIFY21 ***")
  168. end
  169. if {INTEGER_16 0}.bit_not = {INTEGER_16 -1} then
  170. assert(True)
  171. else
  172. c_inline_c("*** WrongCcode #30 in TEST_SIMPLIFY21 ***")
  173. end
  174. if {INTEGER_32 0}.bit_not = {INTEGER_32 -1} then
  175. assert(True)
  176. else
  177. c_inline_c("*** WrongCcode #31 in TEST_SIMPLIFY21 ***")
  178. end
  179. if {INTEGER_64 0}.bit_not = {INTEGER_64 -1} then
  180. assert(True)
  181. else
  182. c_inline_c("*** WrongCcode #32 in TEST_SIMPLIFY21 ***")
  183. end
  184. -- Testing {INTEGER_*}.bit_and:
  185. if 1.bit_and(-1) = 1 then
  186. assert(True)
  187. else
  188. c_inline_c("*** WrongCcode #33 in TEST_SIMPLIFY21 ***")
  189. end
  190. if 193.bit_and(64) = 64 then
  191. assert(True)
  192. else
  193. c_inline_c("*** WrongCcode #34 in TEST_SIMPLIFY21 ***")
  194. end
  195. if 2147483647.bit_and(-1) = 2147483647 then
  196. assert(True)
  197. else
  198. c_inline_c("*** WrongCcode #35 in TEST_SIMPLIFY21 ***")
  199. end
  200. if Minimum_integer_64.bit_and(-1) = Minimum_integer_64 then
  201. assert(True)
  202. else
  203. c_inline_c("*** WrongCcode #36 in TEST_SIMPLIFY21 ***")
  204. end
  205. -- Testing {INTEGER_*}.bit_or:
  206. if 1.bit_or(64) = 65 then
  207. assert(True)
  208. else
  209. c_inline_c("*** WrongCcode #37 in TEST_SIMPLIFY21 ***")
  210. end
  211. if 128.bit_or(1) = 129 then
  212. assert(True)
  213. else
  214. c_inline_c("*** WrongCcode #38 in TEST_SIMPLIFY21 ***")
  215. end
  216. if 32768.bit_or(1) = 32769 then
  217. assert(True)
  218. else
  219. c_inline_c("*** WrongCcode #39 in TEST_SIMPLIFY21 ***")
  220. end
  221. if Maximum_integer_64.bit_or(Minimum_integer_64) = -1 then
  222. assert(True)
  223. else
  224. c_inline_c("*** WrongCcode #40 in TEST_SIMPLIFY21 ***")
  225. end
  226. if Maximum_integer_32.bit_or(Minimum_integer_32) = -1 then
  227. assert(True)
  228. else
  229. c_inline_c("*** WrongCcode #41 in TEST_SIMPLIFY21 ***")
  230. end
  231. if Maximum_integer_16.bit_or(Minimum_integer_16) = -1 then
  232. assert(True)
  233. else
  234. c_inline_c("*** WrongCcode #42 in TEST_SIMPLIFY21 ***")
  235. end
  236. -- Testing {INTEGER_*}.bit_xor:
  237. if Maximum_integer_8.bit_xor(Minimum_integer_8) = -1 then
  238. assert(True)
  239. else
  240. c_inline_c("*** WrongCcode #43 in TEST_SIMPLIFY21 ***")
  241. end
  242. if Maximum_integer_16.bit_xor(Minimum_integer_16) = -1 then
  243. assert(True)
  244. else
  245. c_inline_c("*** WrongCcode #44 in TEST_SIMPLIFY21 ***")
  246. end
  247. if Maximum_integer_32.bit_xor(Minimum_integer_32) = -1 then
  248. assert(True)
  249. else
  250. c_inline_c("*** WrongCcode #45 in TEST_SIMPLIFY21 ***")
  251. end
  252. if Maximum_integer_64.bit_xor(Minimum_integer_64) = -1 then
  253. assert(True)
  254. else
  255. c_inline_c("*** WrongCcode #46 in TEST_SIMPLIFY21 ***")
  256. end
  257. if 128.bit_xor(64) = 192 then
  258. assert(True)
  259. else
  260. c_inline_c("*** WrongCcode #47 in TEST_SIMPLIFY21 ***")
  261. end
  262. -- Testing {INTEGER_*}.#-:
  263. if #- 1 = -1 then
  264. assert(True)
  265. else
  266. c_inline_c("*** WrongCcode #48 in TEST_SIMPLIFY21 ***")
  267. end
  268. if #- 128 = -128 then
  269. assert(True)
  270. else
  271. c_inline_c("*** WrongCcode #49 in TEST_SIMPLIFY21 ***")
  272. end
  273. if #- Minimum_integer_64 = Minimum_integer_64 then
  274. assert(True)
  275. else
  276. c_inline_c("*** WrongCcode #50 in TEST_SIMPLIFY21 ***")
  277. end
  278. assert(assert_counter.item = 51)
  279. end
  280. end -- class TEST_SIMPLIFY21
  281. --
  282. -- ------------------------------------------------------------------------------------------------------------------------------
  283. -- Copyright notice below. Please read.
  284. --
  285. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  286. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  287. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  288. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  289. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  290. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  291. --
  292. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  293. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  294. --
  295. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  296. --
  297. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  298. -- ------------------------------------------------------------------------------------------------------------------------------