/test/language/assertion/test_assertion_all4.e

http://github.com/tybor/Liberty · Specman e · 71 lines · 39 code · 8 blank · 24 comment · 0 complexity · c43611f48cfb0e6c4b4e1044d9aea426 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_ASSERTION_ALL4
  5. --
  6. -- Test for loops.
  7. --
  8. insert
  9. EIFFELTEST_TOOLS
  10. create {}
  11. main
  12. feature {ANY}
  13. variant_counter: INTEGER
  14. invariant_counter: INTEGER
  15. main
  16. local
  17. i: INTEGER
  18. do
  19. assert(variant_counter = 0)
  20. assert(invariant_counter = 0)
  21. from
  22. i := 1
  23. invariant
  24. invariant_call
  25. variant
  26. variant_call - i
  27. until
  28. i > 10
  29. loop
  30. i := i + 1
  31. end
  32. assert(variant_counter = 10)
  33. assert(invariant_counter = 11)
  34. end
  35. variant_call: INTEGER
  36. do
  37. variant_counter := variant_counter + 1
  38. Result := 50
  39. end
  40. invariant_call: BOOLEAN
  41. do
  42. invariant_counter := invariant_counter + 1
  43. Result := True
  44. end
  45. end -- class TEST_ASSERTION_ALL4
  46. --
  47. -- ------------------------------------------------------------------------------------------------------------------------------
  48. -- Copyright notice below. Please read.
  49. --
  50. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  51. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  52. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  53. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  54. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  55. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  56. --
  57. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  58. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  59. --
  60. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  61. --
  62. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  63. -- ------------------------------------------------------------------------------------------------------------------------------