/test/language/exceptions/test_exceptions17.e

http://github.com/tybor/Liberty · Specman e · 101 lines · 65 code · 14 blank · 22 comment · 1 complexity · 951699b155706dce8dc6c43a538fa2c7 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_EXCEPTIONS17
  5. insert
  6. EXCEPTIONS
  7. create {}
  8. make
  9. feature {ANY}
  10. i: INTEGER
  11. make
  12. do
  13. make2
  14. inspect
  15. require_count
  16. when 0, 1 then
  17. is_true(body_count = 1)
  18. is_true(ensure_count = 0)
  19. is_true(rescue_count = 0)
  20. when 2 then
  21. is_true(body_count = 2)
  22. is_true(ensure_count = 2)
  23. is_true(rescue_count = 1)
  24. else
  25. is_true(False)
  26. end
  27. end
  28. make2
  29. require
  30. increment_require_count
  31. do
  32. body_count := body_count + 1
  33. ensure
  34. increment_ensure_count
  35. i /= 0
  36. rescue
  37. rescue_count := rescue_count + 1
  38. i := 1
  39. retry
  40. end
  41. body_count: INTEGER
  42. rescue_count: INTEGER
  43. increment_require_count: BOOLEAN
  44. do
  45. require_count := require_count + 1
  46. Result := True
  47. end
  48. require_count: INTEGER
  49. increment_ensure_count: BOOLEAN
  50. do
  51. ensure_count := ensure_count + 1
  52. Result := True
  53. end
  54. ensure_count: INTEGER
  55. feature {ANY}
  56. is_true (b: BOOLEAN)
  57. do
  58. cpt := cpt + 1
  59. if not b then
  60. crash
  61. std_output.put_string("TEST_EXCEPTION17: ERROR Test # ")
  62. std_output.put_integer(cpt)
  63. std_output.put_string("%N")
  64. else
  65. --std_output.put_string("Yes%N");
  66. end
  67. end
  68. cpt: INTEGER
  69. end -- class TEST_EXCEPTIONS17
  70. --
  71. -- ------------------------------------------------------------------------------------------------------------------------------
  72. -- Copyright notice below. Please read.
  73. --
  74. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  75. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  76. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  77. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  78. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  79. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  80. --
  81. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  82. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  83. --
  84. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  85. --
  86. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  87. -- ------------------------------------------------------------------------------------------------------------------------------