/[eiffelstudio]/trunk/eweasel/tests/syntax045/test.e
ViewVC logotype

Contents of /trunk/eweasel/tests/syntax045/test.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88481 - (show annotations)
Thu Mar 29 17:49:33 2012 UTC (7 years, 10 months ago) by alexk
File size: 7169 byte(s)
Changed expected content of verbatim strings to take into acccount that empty lines and empty lines with blanks are considered as different.
1 indexing
2
3 meaning:
4 "$(OPEN)
5 This verbatim string should never be reported
6 in a warning, because it is written in indexing clause.
7 $(CLOSE)"
8
9 class TEST
10
11 create
12
13 make
14
15 feature {NONE} -- Creation
16
17 make is
18 -- Execute test.
19 do
20 -- Empty verbatim strings
21 test_equality (
22 "$(OPEN)
23 $(CLOSE)",
24 ""
25 )
26 test_equality (
27 "$(OPEN)
28 $(CLOSE)",
29 ""
30 )
31 test_equality (
32 "$(OPEN)
33 $(CLOSE)",
34 ""
35 )
36 -- Verbatim strings with empty lines only
37 test_equality (
38 "$(OPEN)
39 $(EMPTY)
40 $(CLOSE)",
41 ""
42 )
43 test_equality (
44 "$(OPEN)
45 $(EMPTY)
46 $(CLOSE)",
47 "$(INDENT)"
48 )
49 test_equality (
50 "$(OPEN)
51 $(EMPTY)
52 $(EMPTY)
53 $(CLOSE)",
54 "%N"
55 )
56 test_equality (
57 "$(OPEN)
58 $(EMPTY)
59 $(EMPTY)
60 $(CLOSE)",
61 "$(INDENT)%N$(INDENT)"
62 )
63 test_equality (
64 "$(OPEN)
65 $(EMPTY)
66 $(EMPTY)
67 $(CLOSE)",
68 "%N%T%T%T%T"
69 )
70 test_equality (
71 "$(OPEN)
72 $(EMPTY)
73 $(EMPTY)
74 $(CLOSE)",
75 "%T%T%T%T%N"
76 )
77 -- Verbatim strings with data
78 test_equality (
79 "$(OPEN)
80 ABC
81 $(CLOSE)",
82 "$(INDENT)ABC"
83 )
84 test_equality (
85 "$(OPEN)
86 ABC
87 abc
88 $(CLOSE)",
89 "$(INDENT)ABC%N$(INDENT)abc"
90 )
91 test_equality (
92 "$(OPEN)
93 ABC
94 $(CLOSE)",
95 "$(INDENT)ABC %T"
96 )
97 test_equality (
98 "$(OPEN)
99 ABC
100 abc
101 $(CLOSE)",
102 "$(INDENT)ABC%N$(INDENT) abc"
103 )
104 test_equality (
105 "$(OPEN)
106 ABC
107 abc
108 $(CLOSE)",
109 "$(INDENT) ABC%N$(INDENT)abc"
110 )
111 test_equality (
112 "$(OPEN)
113 ABC
114 abc
115 $(CLOSE)",
116 "$(INDENT)$(SPACE)ABC%N$(INDENT)$(SPACE)abc"
117 )
118 -- Verbatim strings with data and empty lines
119 test_equality (
120 "$(OPEN)
121 $(EMPTY)
122 abc
123 $(CLOSE)",
124 "%N%T%T%T%Tabc"
125 )
126 test_equality (
127 "$(OPEN)
128 $(EMPTY)
129 abc
130 $(CLOSE)",
131 "$(INDENT)%N$(INDENT)abc"
132 )
133 test_equality (
134 "$(OPEN)
135 $(EMPTY)
136 abc
137 $(EMPTY)
138 $(CLOSE)",
139 "%N%T%T%T%Tabc%N"
140 )
141 test_equality (
142 "$(OPEN)
143 $(EMPTY)
144 abc
145 $(EMPTY)
146 $(CLOSE)",
147 "$(INDENT)%N$(INDENT)abc%N$(INDENT)"
148 )
149 test_equality (
150 "$(OPEN)
151 $(EMPTY)
152 abc
153 $(EMPTY)
154 $(CLOSE)",
155 "%N%T%T%T%Tabc%N%T%T%T%T"
156 )
157 test_equality (
158 "$(OPEN)
159 $(EMPTY)
160 abc
161 $(EMPTY)
162 $(CLOSE)",
163 "%T%T%T%T%N%T%T%T%Tabc%N"
164 )
165 test_equality (
166 "$(OPEN)
167 $(EMPTY)
168 abc
169 $(EMPTY)
170 ABC
171 $(EMPTY)
172 $(CLOSE)",
173 "%N%T%T%T%Tabc%N%N%T%T%T%TABC%N"
174 )
175 test_equality (
176 "$(OPEN)
177 $(EMPTY)
178 abc
179 $(EMPTY)
180 ABC
181 $(EMPTY)
182 $(CLOSE)",
183 "$(INDENT)%N$(INDENT)abc%N$(INDENT)%N$(INDENT)ABC%N$(INDENT)"
184 )
185 -- Verbatim strings with special data
186 test_equality (
187 "$(OPEN)
188 $(CLOSE)
189 $(CLOSE)",
190 "$(INDENT)%/$(CLOSE_CODE)/"
191 )
192 test_equality (
193 "$(OPEN)
194 $(CLOSE)
195 $(CLOSE)
196 $(CLOSE)",
197 "$(INDENT)%/$(CLOSE_CODE)/%N$(INDENT)%/$(CLOSE_CODE)/"
198 )
199 test_equality (
200 "$(OPEN)
201 $(CLOSE)
202 $(CLOSE)",
203 "$(INDENT)%/$(CLOSE_CODE)/ %T"
204 )
205 test_equality (
206 "$(OPEN)
207 $(CLOSE)
208 $(CLOSE)
209 $(CLOSE)",
210 "$(INDENT)%/$(CLOSE_CODE)/%N$(INDENT) %/$(CLOSE_CODE)/"
211 )
212 test_equality (
213 "$(OPEN)
214 $(CLOSE)
215 $(CLOSE)
216 $(CLOSE)",
217 "$(INDENT) %/$(CLOSE_CODE)/%N$(INDENT)%/$(CLOSE_CODE)/"
218 )
219 test_equality (
220 "$(OPEN)
221 $(CLOSE)
222 $(CLOSE)
223 $(CLOSE)",
224 "$(INDENT)$(SPACE)%/$(CLOSE_CODE)/%N$(INDENT)$(SPACE)%/$(CLOSE_CODE)/"
225 )
226 test_equality (
227 "$(OPEN)
228 ABC$(CLOSE)"
229 $(CLOSE)",
230 "$(INDENT)ABC%/$(CLOSE_CODE)/%""
231 )
232 test_equality (
233 "$(OPEN)
234 ABC$(CLOSE)"
235 abc$(CLOSE)"
236 $(CLOSE)",
237 "$(INDENT)ABC%/$(CLOSE_CODE)/%"%N$(INDENT)abc%/$(CLOSE_CODE)/%""
238 )
239 test_equality (
240 "$(OPEN)
241 ABC$(CLOSE)"
242 $(CLOSE)",
243 "$(INDENT)ABC%/$(CLOSE_CODE)/%" %T"
244 )
245 test_equality (
246 "$(OPEN)
247 ABC$(CLOSE)"
248 abc$(CLOSE)"
249 $(CLOSE)",
250 "$(INDENT)ABC%/$(CLOSE_CODE)/%"%N$(INDENT) abc%/$(CLOSE_CODE)/%""
251 )
252 test_equality (
253 "$(OPEN)
254 ABC$(CLOSE)"
255 abc$(CLOSE)"
256 $(CLOSE)",
257 "$(INDENT) ABC%/$(CLOSE_CODE)/%"%N$(INDENT)abc%/$(CLOSE_CODE)/%""
258 )
259 test_equality (
260 "$(OPEN)
261 ABC$(CLOSE)"
262 abc$(CLOSE)"
263 $(CLOSE)",
264 "$(INDENT)$(SPACE)ABC%/$(CLOSE_CODE)/%"%N$(INDENT)$(SPACE)abc%/$(CLOSE_CODE)/%""
265 )
266 test_equality (
267 "$(OPEN)
268 ABC$(CLOSE)
269 $(CLOSE)",
270 "$(INDENT)ABC%/$(CLOSE_CODE)/"
271 )
272 test_equality (
273 "$(OPEN)
274 ABC$(CLOSE)
275 abc$(CLOSE)
276 $(CLOSE)",
277 "$(INDENT)ABC%/$(CLOSE_CODE)/%N$(INDENT)abc%/$(CLOSE_CODE)/"
278 )
279 test_equality (
280 "$(OPEN)
281 ABC$(CLOSE)
282 $(CLOSE)",
283 "$(INDENT)ABC%/$(CLOSE_CODE)/ %T"
284 )
285 test_equality (
286 "$(OPEN)
287 ABC$(CLOSE)
288 abc$(CLOSE)
289 $(CLOSE)",
290 "$(INDENT)ABC%/$(CLOSE_CODE)/%N$(INDENT) abc%/$(CLOSE_CODE)/"
291 )
292 test_equality (
293 "$(OPEN)
294 ABC$(CLOSE)
295 abc$(CLOSE)
296 $(CLOSE)",
297 "$(INDENT) ABC%/$(CLOSE_CODE)/%N$(INDENT)abc%/$(CLOSE_CODE)/"
298 )
299 test_equality (
300 "$(OPEN)
301 ABC$(CLOSE)
302 abc$(CLOSE)
303 $(CLOSE)",
304 "$(INDENT)$(SPACE)ABC%/$(CLOSE_CODE)/%N$(INDENT)$(SPACE)abc%/$(CLOSE_CODE)/"
305 )
306 test_equality (
307 "$(OPEN)
308 $(CLOSE_OTHER)"
309 $(CLOSE)",
310 "$(INDENT)%/$(CLOSE_OTHER_CODE)/%""
311 )
312 -- Verbatim strings with non-empty opener and closer
313 test_equality (
314 "++$(OPEN)
315 ]"
316 $(CLOSE)++",
317 "$(INDENT)%/93/%""
318 )
319 test_equality (
320 "++$(OPEN)
321 }"
322 $(CLOSE)++",
323 "$(INDENT)%/125/%""
324 )
325 test_equality (
326 "%$(OPEN)
327 $(CLOSE)%",
328 ""
329 )
330 test_equality (
331 "$(OPEN)%
332 %$(CLOSE)",
333 "%/$(OPEN_CODE)/%/$(CLOSE_CODE)/"
334 )
335 test_equality (
336 "$(OPEN)$(CLOSE)",
337 "%/$(OPEN_CODE)/%/$(CLOSE_CODE)/"
338 )
339 end
340
341 feature {NONE} -- Tests
342
343 test_number: INTEGER
344 -- Last test number
345
346 test_equality (s1, s2: STRING) is
347 -- Check if `s1' and `s2' are not void and are equal.
348 do
349 test_number := test_number + 1
350 io.put_string ("Test " + test_number.out + ": ")
351 if s1 ~ s2 then
352 io.put_string ("OK%N")
353 else
354 io.put_string ("FAILED: ")
355 print_string (s1)
356 io.put_string (" instead of ")
357 print_string (s2)
358 io.put_character ('%N')
359 end
360 ensure
361 test_number_increased: test_number = old test_number + 1
362 end
363
364 feature {NONE} -- Output
365
366 print_string (s: STRING) is
367 -- Print string `s' escaping special characters.
368 local
369 i: INTEGER
370 c: CHARACTER
371 do
372 io.put_character ('%"')
373 from
374 i := 1
375 until
376 i > s.count
377 loop
378 c := s.item (i)
379 inspect c
380 when
381 '%/0/' .. '%/8/',
382 '%/10/' .. '%/31/', '%/127/' .. '%/255/' then
383 io.put_string ("%%/")
384 io.put_integer (c.code)
385 io.put_character ('/')
386 when '%"' then
387 io.put_string ("%%%"")
388 when '%%' then
389 io.put_string ("%%%%")
390 when '%'' then
391 io.put_string ("%%%'")
392 when '%T' then
393 io.put_string ("%%T")
394 else
395 io.put_character (c)
396 end
397 i := i + 1
398 end
399 io.put_character ('%"')
400 end
401
402 invariant
403
404 non_negative_test_number: test_number >= 0
405
406 indexing
407
408 meaning:
409 "$(OPEN)
410 This verbatim string should never be reported
411 in a warning, because it is written in indexing clause.
412 $(CLOSE)"
413
414 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23