/test/language/simplify/test_simplify03.e

http://github.com/tybor/Liberty · Specman e · 152 lines · 106 code · 16 blank · 30 comment · 9 complexity · 269797b00855820639dfd08426f9983a 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_SIMPLIFY03
  5. --
  6. -- To check that the simplify work is actually done (for -boost mode only).
  7. --
  8. -- Special test for precomputable once routines.
  9. --
  10. inherit
  11. EIFFELTEST_TOOLS
  12. create {}
  13. make
  14. create {TEST_SIMPLIFY03}
  15. make_1, make_2, make_like_string
  16. feature {}
  17. make
  18. do
  19. assert_counter.reset
  20. assert(assert_counter.item = 0)
  21. -- The generated C code is now a very simple sequence of assert calls :-)
  22. if once_counter = Void then
  23. c_inline_c("*NoCcodeGenerated01")
  24. else
  25. assert(assert_counter.item = 1)
  26. end
  27. if once_counter /= Void then
  28. assert(assert_counter.item = 2)
  29. else
  30. c_inline_c("*NoCcodeGenerated02")
  31. end
  32. if once_string = Void then
  33. c_inline_c("*NoCcodeGenerated03")
  34. else
  35. assert(assert_counter.item = 3)
  36. end
  37. if once_string.lower = 0 then
  38. c_inline_c("*NoCcodeGenerated04")
  39. else
  40. assert(assert_counter.item = 4)
  41. end
  42. if once_make_1 = Void then
  43. c_inline_c("*NoCcodeGenerated05")
  44. else
  45. assert(assert_counter.item = 5)
  46. end
  47. if once_make_2 = Void then
  48. c_inline_c("*NoCcodeGenerated06")
  49. else
  50. assert(assert_counter.item = 6)
  51. end
  52. if once_make_like_string = Void then
  53. c_inline_c("*NoCcodeGenerated07")
  54. else
  55. assert(assert_counter.item = 7)
  56. end
  57. if once_make_tuple.count /= 2 then
  58. c_inline_c("*NoCcodeGenerated08")
  59. else
  60. assert(assert_counter.item = 8)
  61. end
  62. end
  63. once_make_1: TEST_SIMPLIFY03
  64. once
  65. create Result.make_1
  66. end
  67. once_make_2: TEST_SIMPLIFY03
  68. once
  69. create Result.make_2
  70. end
  71. once_make_like_string: TEST_SIMPLIFY03
  72. once
  73. create Result.make_like_string(0)
  74. end
  75. once_make_tuple: TUPLE[INTEGER_8, CHARACTER]
  76. once
  77. Result := [1, 'A']
  78. end
  79. make_1
  80. local
  81. i: INTEGER
  82. do
  83. i := i + 1
  84. end
  85. make_2
  86. local
  87. i: INTEGER
  88. do
  89. i := i + 1
  90. i := i - 2
  91. end
  92. capacity, count: INTEGER
  93. storage: NATIVE_ARRAY[CHARACTER]
  94. make_like_string (needed_capacity: INTEGER)
  95. -- Initialize the string to have at least `needed_capacity' characters of storage.
  96. require
  97. non_negative_size: needed_capacity >= 0
  98. do
  99. if needed_capacity > 0 then
  100. -- if capacity < needed_capacity then
  101. storage := (create {NATIVE_ARRAY[CHARACTER]}).calloc(needed_capacity)
  102. capacity := needed_capacity
  103. -- end
  104. end
  105. count := 0
  106. ensure
  107. needed_capacity <= capacity
  108. empty_string: count = 0
  109. end
  110. once_counter: COUNTER
  111. once
  112. create Result
  113. end
  114. once_string: STRING
  115. once
  116. Result := once ""
  117. end
  118. end -- class TEST_SIMPLIFY03
  119. --
  120. -- ------------------------------------------------------------------------------------------------------------------------------
  121. -- Copyright notice below. Please read.
  122. --
  123. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  124. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  125. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  126. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  127. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  128. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  129. --
  130. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  131. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  132. --
  133. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  134. --
  135. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  136. -- ------------------------------------------------------------------------------------------------------------------------------