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

/test/language/simplify/test_simplify02.e

http://github.com/tybor/Liberty
Specman e | 388 lines | 349 code | 11 blank | 28 comment | 39 complexity | 8bb2066d6278845c9a7ccb64a9e502e5 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_SIMPLIFY02
  5   --
  6   -- To check that the simplify work is actually done (for -boost mode only).
  7   --
  8
  9inherit
 10   EIFFELTEST_TOOLS
 11
 12create {}
 13   make
 14
 15feature {ANY}
 16   null_pointer: POINTER
 17      do
 18      end
 19
 20   make
 21      local
 22         b_true, b_false: BOOLEAN; local_pointer: POINTER
 23      do
 24         b_true := True
 25         b_false := False
 26         if True then
 27            always_run
 28         else
 29            c_inline_c("NoCcodeGenerated01")
 30         end
 31         if False then
 32            c_inline_c("NoCcodeGenerated02")
 33         else
 34            always_run
 35         end
 36         if False then
 37            c_inline_c("NoCcodeGenerated03")
 38         elseif True then
 39            always_run
 40         else
 41            c_inline_c("NoCcodeGenerated04")
 42         end
 43         if 3 = 3 then
 44            always_run
 45         else
 46            c_inline_c("NoCcodeGenerated05")
 47         end
 48         if always_false then
 49            c_inline_c("NoCcodeGenerated06")
 50         end
 51         if always_true then
 52            always_run
 53         end
 54         if True then
 55            always_run
 56         end
 57         if False then
 58         else
 59            always_run
 60         end
 61         if False then
 62            c_inline_c("NoCcodeGenerated07")
 63         elseif False then
 64            c_inline_c("NoCcodeGenerated08")
 65         elseif True then
 66            always_run
 67         elseif True then
 68            c_inline_c("NoCcodeGenerated09")
 69         else
 70            c_inline_c("NoCcodeGenerated10")
 71         end
 72         if False then
 73            c_inline_c("NoCcodeGenerated11")
 74         elseif False then
 75            c_inline_c("NoCcodeGenerated12")
 76         elseif True then
 77            always_run
 78         elseif b_true then
 79            c_inline_c("NoCcodeGenerated13")
 80         else
 81            c_inline_c("NoCcodeGenerated14")
 82         end
 83         if b_false then
 84            assert(False)
 85         elseif False then
 86            c_inline_c("NoCcodeGenerated15")
 87         elseif True then
 88            always_run
 89         elseif b_true then
 90            c_inline_c("NoCcodeGenerated16")
 91         else
 92            c_inline_c("NoCcodeGenerated17")
 93         end
 94         if False then
 95            c_inline_c("NoCcodeGenerated18")
 96         elseif always_false then
 97            c_inline_c("NoCcodeGenerated19")
 98         else
 99            always_run
100         end
101         if b_true then
102            always_run
103         elseif always_false then
104            c_inline_c("NoCcodeGenerated20")
105         elseif always_false then
106            c_inline_c("NoCcodeGenerated21")
107         else
108            assert(False)
109         end
110         if 4 #\\ 2 = 0 then
111            always_run
112         else
113            c_inline_c("NoCcodeGenerated22")
114         end
115         if 4 #// 2 = 2 then
116            always_run
117         else
118            c_inline_c("NoCcodeGenerated23")
119         end
120         if not True then
121            c_inline_c("NoCcodeGenerated24")
122         end
123         if 3 = 0 then
124            c_inline_c("NoCcodeGenerated25")
125         else
126            always_run
127         end
128         if 3.6 = 3.6 then
129            always_run
130         else
131            c_inline_c("NoCcodeGenerated26")
132         end
133         if 0 = 1 then
134            c_inline_c("NoCcodeGenerated27")
135         else
136            always_run
137         end
138         if 1 = 0 then
139            c_inline_c("NoCcodeGenerated28")
140         else
141            always_run
142         end
143         if 2 = 2 and 3 /= 3 then
144            c_inline_c("NoCcodeGenerated29")
145         end
146         if True /= False then
147            always_run
148         else
149            c_inline_c("NoCcodeGenerated30")
150         end
151         if null_pointer = default_pointer then
152            always_run
153         else
154            c_inline_c("NoCcodeGenerated31")
155         end
156         if null_pointer /= default_pointer then
157            c_inline_c("NoCcodeGenerated32")
158         else
159            assert(null_pointer = default_pointer)
160         end
161         if "foo" = Void then
162            c_inline_c("NoCcodeGenerated33")
163         else
164            always_run
165         end
166         if {FAST_ARRAY[STRING] << "foo" >> } = Void then
167            c_inline_c("NoCcodeGenerated34")
168         else
169            always_run
170         end
171         if True = False then
172            c_inline_c("NoCcodeGenerated35")
173         else
174            always_run
175         end
176         if local_pointer /= is_void.to_pointer then
177            assert(False)
178            -- No data flow analysis at time being (july 12th 2004)
179         else
180            always_run
181         end
182         if local_pointer = is_void.to_pointer then
183            assert(local_pointer = default_pointer)
184         else
185            assert(False)
186            -- No data flow analysis at time being (july 12th 2004)
187         end
188         if "foo" /= Void then
189            always_run
190         else
191            c_inline_c("NoCcodeGenerated38")
192         end
193         if {ARRAY[STRING] 1, << "foo" >> } /= Void then
194            always_run
195         else
196            c_inline_c("NoCcodeGenerated39")
197         end
198         if 4 = 4 then
199            always_run
200         else
201            c_inline_c("NoCcodeGenerated40")
202         end
203         if 2 + 2 - 2 = 2 then
204            always_run
205         else
206            c_inline_c("NoCcodeGenerated41")
207         end
208         if two = 2 then
209            always_run
210         else
211            c_inline_c("NoCcodeGenerated42")
212         end
213         if 2 + two = 4 then
214            always_run
215         else
216            c_inline_c("NoCcodeGenerated43")
217         end
218         if is_void = Void then
219            always_run
220         else
221            c_inline_c("NoCcodeGenerated44")
222         end
223         if is_void /= Void then
224            c_inline_c("NoCcodeGenerated45")
225         else
226            always_run
227         end
228         assert(assert_counter.item = 34)
229         -- Extra test for inspect statements on CHARACTERs:
230         inspect
231            'b'
232         when 'a' then
233            c_inline_c("NoCcodeGenerated46")
234         else
235            always_run
236         end
237         inspect
238            'b'
239         when 'a' then
240            c_inline_c("NoCcodeGenerated47")
241         when 'b' then
242            always_run
243         else
244            c_inline_c("NoCcodeGenerated48")
245         end
246         inspect
247            'b'
248         when 'a' then
249            c_inline_c("NoCcodeGenerated49")
250         when 'b' then
251            always_run
252         when 'c' then
253            c_inline_c("NoCcodeGenerated50")
254         end
255         inspect
256            'e'
257         when 'a' .. 'b' then
258            c_inline_c("NoCcodeGenerated51")
259         else
260            always_run
261         end
262         inspect
263            'e'
264         when 'a' .. 'b' then
265            c_inline_c("NoCcodeGenerated52")
266         when 'c' .. 'e' then
267            always_run
268         else
269            c_inline_c("NoCcodeGenerated53")
270         end
271         inspect
272            'e'
273         when 'a' .. 'd' then
274            c_inline_c("NoCcodeGenerated54")
275         when 'e' .. 'f' then
276            always_run
277         when 'g' then
278            c_inline_c("NoCcodeGenerated55")
279         end
280         assert(assert_counter.item = 41)
281         -- Extra test for inspect statements on INTEGERs:
282         inspect
283            2
284         when 1 then
285            c_inline_c("NoCcodeGenerated56")
286         else
287            always_run
288         end
289         inspect
290            2
291         when 1 then
292            c_inline_c("NoCcodeGenerated57")
293         when 2 then
294            always_run
295         else
296            c_inline_c("NoCcodeGenerated58")
297         end
298         inspect
299            2
300         when 1 then
301            c_inline_c("NoCcodeGenerated59")
302         when 2 then
303            always_run
304         when 3 then
305            c_inline_c("NoCcodeGenerated60")
306         end
307         inspect
308            5
309         when 1 .. 2 then
310            c_inline_c("NoCcodeGenerated61")
311         else
312            always_run
313         end
314         inspect
315            5
316         when 1 .. 2 then
317            c_inline_c("NoCcodeGenerated62")
318         when 3 .. 5 then
319            always_run
320         else
321            c_inline_c("NoCcodeGenerated63")
322         end
323         inspect
324            5
325         when 1 .. 4 then
326            c_inline_c("NoCcodeGenerated64")
327         when 5 .. 6 then
328            always_run
329         when 7 then
330            c_inline_c("NoCcodeGenerated65")
331         end
332         assert(assert_counter.item = 48)
333         assert(assert_counter.item = 49)
334         if {RING_ARRAY[STRING] 1, << "foo" >> } /= Void then
335            always_run
336         else
337            c_inline_c("NoCcodeGenerated66")
338         end
339         if 2 + {INTEGER_32 2 } = 4 then
340            always_run
341         else
342            c_inline_c("NoCcodeGenerated67")
343         end
344
345      end
346
347   is_void: ANY
348      do
349      end
350
351   two: INTEGER
352      do
353         Result := 1 + 1
354      end
355
356   always_run
357      do
358         assert(True)
359      end
360
361   always_true: BOOLEAN
362      do
363         Result := True
364      end
365
366   always_false: BOOLEAN
367      do
368      end
369
370end -- class TEST_SIMPLIFY02
371--
372-- ------------------------------------------------------------------------------------------------------------------------------
373-- Copyright notice below. Please read.
374--
375-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
376-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
377-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
378-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
379-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
380-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
381--
382-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
383-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
384--
385-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
386--
387-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
388-- ------------------------------------------------------------------------------------------------------------------------------