/test/language/instruction/loop/test_loop_variant2.e

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