PageRenderTime 18ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/language/unclassified/test_once8.e

http://github.com/tybor/Liberty
Specman e | 130 lines | 86 code | 15 blank | 29 comment | 0 complexity | 73d9e1b9c63bc9f25953b289b19bfcb5 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--
  4class TEST_ONCE8
  5   --
  6   -- To memorize the result of a discussion at the last ECMA we agree with.
  7   --
  8   -- Pre--post condition of once must be checked at every calls (they
  9   -- are part of the interface).
 10   -- Dom. feb 18th 2004, just back from Orinda CA.
 11   --
 12
 13inherit
 14   EIFFELTEST_TOOLS
 15
 16create {}
 17   make
 18
 19feature {ANY}
 20   require_trace: STRING
 21      once
 22         create Result.make(0)
 23      end
 24
 25   body_trace: STRING
 26      once
 27         create Result.make(0)
 28      end
 29
 30   ensure_trace: STRING
 31      once
 32         create Result.make(0)
 33      end
 34
 35   update_trace (actual_trace: STRING; step_mark: STRING): BOOLEAN
 36      do
 37         actual_trace.append(step_mark)
 38         Result := True
 39      end
 40
 41   once_procedure (step_mark: STRING)
 42      require
 43         update_trace(require_trace, "RP")
 44      once
 45         body_trace.append(step_mark)
 46      ensure
 47         update_trace(ensure_trace, "EP")
 48      end
 49
 50   make
 51      local
 52         require_trace_view, ensure_trace_view, once_function_result: STRING
 53      do
 54         setup_flags
 55         -- To ease debug:
 56         require_trace_view := require_trace
 57         ensure_trace_view := ensure_trace
 58         assert(require_trace.is_empty)
 59         assert(body_trace.is_empty)
 60         assert(ensure_trace.is_empty)
 61         once_procedure("1")
 62         assert(require_flag implies require_trace.is_equal("RP"))
 63         assert(body_trace.is_equal("1"))
 64         assert(ensure_flag implies ensure_trace.is_equal("EP"))
 65         once_procedure("2")
 66         assert(require_flag implies require_trace.is_equal("RPRP"))
 67         assert(body_trace.is_equal("1"))
 68         assert(ensure_flag implies ensure_trace.is_equal("EPEP"))
 69         require_trace.clear_count
 70         ensure_trace.clear_count
 71         once_function_result := once_function("call_1")
 72         assert(require_flag implies require_trace.is_equal("RP"))
 73         assert(ensure_flag implies ensure_trace.is_equal("EP"))
 74         assert(once_function("call_2") = once_function_result)
 75         assert(require_flag implies require_trace.is_equal("RPRP"))
 76         assert(ensure_flag implies ensure_trace.is_equal("EPEP"))
 77      end
 78
 79   require_flag: BOOLEAN
 80
 81   set_require_flag: BOOLEAN
 82      do
 83         require_flag := True
 84         Result := True
 85      end
 86
 87   ensure_flag: BOOLEAN
 88
 89   set_ensure_flag: BOOLEAN
 90      do
 91         ensure_flag := True
 92         Result := True
 93      end
 94
 95   setup_flags
 96      require
 97         set_require_flag
 98      do
 99      ensure
100         set_ensure_flag
101      end
102
103   once_function (step_mark: STRING): STRING
104      require
105         update_trace(require_trace, "RP")
106      once
107         Result := step_mark.twin
108      ensure
109         update_trace(ensure_trace, "EP")
110      end
111
112end -- class TEST_ONCE8
113--
114-- ------------------------------------------------------------------------------------------------------------------------------
115-- Copyright notice below. Please read.
116--
117-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
118-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
119-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
120-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
121-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
122-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
123--
124-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
125-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
126--
127-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
128--
129-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
130-- ------------------------------------------------------------------------------------------------------------------------------