PageRenderTime 18ms CodeModel.GetById 8ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

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