Subversion Repositories wimsdev

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8192 georgesk 1
# -*- coding: latin-1 -*-
2
== simple assignement ==
3
 bar=just a test
4
 foo=another test
5
----
6
bar == just a test
7
foo == another test
8
== !append word ==
9
 # test of the command !append 
10
 foo=Hello
11
 foo=!append word World to $foo
12
----
13
foo == Hello World
14
== !append item ==
15
 # test of the command !append 
16
 foo=Hello Roméo
17
 foo=!append item Juliette to $foo
18
----
19
foo == Hello Roméo,Juliette
20
== !append line ==
21
 foo=
22
 !for i=1 to 5
23
   foo=!append line Here is the line $i to $foo
24
 !next i
25
----
26
foo == Here is the line 1
27
Here is the line 2
28
Here is the line 3
29
Here is the line 4
30
Here is the line 5
31
== !char ==
32
 phrase=Bonjour François
33
 foo=!char 1,3,5,7,9,11,13,15 of $phrase
34
----
35
foo == BnorFaçi
36
== !charcnt ==
37
 foo=!charcnt BONJOUR
38
----
39
foo == 7
40
== !column ==
41
 matrix=a1,a2,a3;b1,b2,b3;c1,c2,c3
42
 foo=!column 1,3 of $matrix
43
----
44
foo == a1, a3;b1, b3;c1, c3
45
== !deaccent ==
46
foo=!deaccent àâä-éèêë-îï-öô-ùûü-ç-ÀÂÄ-ÈÉÊË-ÎÏ-ÔÖ-ÙÛÜ-Ç
47
----
48
foo == aaa-eeee-ii-oo-uuu-c-AAA-EEEE-II-OO-UUU-C
49
== !declosing ==
50
 foo=!declosing (1+2+3+4)
51
----
52
foo == 1+2+3+4
53
== !defof ==
54
 # no test since it implies an external file. Maybe something should be
55
 # implemented to support extra files.
56
== !detag ==
57
 foo=!detag <a_strange_html_tag>Hello</another_strange_html_tag>
58
----
59
foo == Hello
60
== !embraced ==
61
 foo=!embraced extract {à{b}}c
62
 bar=!embraced extract $foo 
63
----
64
foo == à{b}
65
bar == b
66
== !eval ==
67
 foo=!eval 2*pi
68
----
69
foo == 6.2831853
70
== !evalsubst ==
71
 # this primitive is very basic, so it features some bugs, see below.
72
 f=x^2+x+1
73
 foo=!evalsubst x=(-1) in $f
74
 bar=!evalsubst x=-1 in $f
75
----
76
foo == 1
77
bar == -1
78
== !getopt ==
79
 phrase=hello=bonjour in French
80
 foo=!getopt hello in $phrase
81
 bar=!getopt bonjour in $phrase
82
 baz=!getopt hallo in $phrase
83
 phrase=hello="Guten Tag" in German
84
 plop=!getopt hello in $phrase
85
----
86
foo == bonjour
87
bar == bonjour
88
baz == 
89
plop == Guten Tag
90
== !hex ==
91
 foo=!hex Eh bien, çà donc !
92
----
93
foo == 4568206269656E2C20E7E020646F6E632021
94
== !htmlmath ==
95
 foo=!htmlmath 2E5
96
----
97
foo == 2 &times; 10<sup>5</sup>
98
== !item ==
99
 liste=un,verre,ça,va,trois,verres,bonjour,les dégâts
100
 foo=!item -5..-1 of $liste
101
----
102
foo == va, trois, verres, bonjour, les dégâts
103
== !itemcnt ==
104
 liste=un,verre,ça,va,trois,verres,bonjour,les dégâts
105
 foo=!itemcnt $liste
106
----
107
foo == 8
108
== !items2lines ==
109
 liste=un,verre,ça,va,trois,verres,bonjour,les dégâts
110
 foo=!items2lines $liste
111
----
112
foo == un
113
verre
114
ça
115
va
116
trois
117
verres
118
bonjour
119
les dégâts
120
== !items2words ==
121
 liste=un,verre,ça,va,trois,verres,bonjour,les dégâts
122
 foo=!items2words $liste
123
----
124
foo == un verre ça va trois verres bonjour les dégâts
125
== !line ==
126
 phrase=Maître corbeau, sur son arbre perché,\
127
 Tenait en son bec un fromage.\
128
 Maître Renard, par l'odeur alléché,\
129
 Lui tint à peu près ce langage :
130
 foo=!line 2..-1 of $phrase
131
----
132
foo == Tenait en son bec un fromage.
133
Maître Renard, par l'odeur alléché,
134
Lui tint à peu près ce langage :
135
== !linecnt ==
136
 phrase=Maître corbeau, sur son arbre perché,\
137
 Tenait en son bec un fromage.\
138
 Maître Renard, par l'odeur alléché,\
139
 Lui tint à peu près ce langage :
140
 foo=!linecnt $phrase
141
----
142
foo == 4
143
== !line2items ==
144
 phrase=Maître corbeau, sur son arbre perché,\
145
 Tenait en son bec un fromage.\
146
 Maître Renard, par l'odeur alléché,\
147
 Lui tint à peu près ce langage :
148
 foo=!lines2items $phrase
149
----
150
foo == Maître corbeau, sur son arbre perché,,Tenait en son bec un fromage.,Maître Renard, par l'odeur alléché,,Lui tint à peu près ce langage :
151
== !lines2words ==
152
 phrase=Maître corbeau, sur son arbre perché,\
153
 Tenait en son bec un fromage.\
154
 Maître Renard, par l'odeur alléché,\
155
 Lui tint à peu près ce langage :
156
 foo=!lines2words $phrase
157
----
158
foo == Maître corbeau, sur son arbre perché, Tenait en son bec un fromage. Maître Renard, par l'odeur alléché, Lui tint à peu près ce langage :
159
== !listcomplement ==
160
 l1=a,c,d,e,f,h
161
 l2=a,b,d,e,g,i,j
162
 foo=!listcomplement $l1 in $l2
163
 bar=!listcomplement $l2 in $l1
164
----
165
foo == b,g,i,j
166
bar == c,f,h
167
== !listintersect ==
168
 l1=a,c,d,e,f,h
169
 l2=a,b,d,e,g,i,j
170
 foo=!listintersect $l1 and $l2
171
----
172
foo == a,d,e
173
== !listunion ==
174
 l1=a,c,d,e,f,h
175
 l2=a,b,d,e,g,i,j
176
 foo=!listunion $l1 and $l2
177
 bar=!listunion $l2 and $l1
178
----
179
foo == a,c,d,e,f,h,b,g,i,j
180
bar == a,b,d,e,g,i,j,c,f,h
181
== !lituniq ==
182
 foo=!listuniq a,a,b,b,a,c,d,c
183
----
184
foo == a,b,c,d
185
== !lookup ==
186
 # no test since it implies an external file. Maybe something should be
187
 # implemented to support extra files.
188
== !lower ==
189
# cannot lower accented chars ... is it a feature?
190
 foo=!lower BONJOUR ÀÂÄ-ÈÉÊË-ÎÏ-ÔÖ-ÙÛÜ-Ç
191
----
192
foo == bonjour ÀÂÄ-ÈÉÊË-ÎÏ-ÔÖ-ÙÛÜ-Ç
193
== !makelist ==
194
# this example comes from the technical documentation of Wims
195
 foo=!makelist [x;x+1;xx] for x in a,x and y,1,(2,3)
196
----
197
foo == [a;a+1;xx],[x and y;x and y+1;xx],[1;1+1;xx],[(2,3);(2,3)+1;xx]
198
== !mathsubst ==
199
 foo=!mathsubst x=y in [a;a+1;xx],[x and y;x and y+1;xx],[1;1+1;xx],[(2,3);(2,3)+1;xx]
200
----
201
foo == [a;a+1;xx],[y and y;y and y+1;xx],[1;1+1;xx],[(2,3);(2,3)+1;xx]
202
== !nonempty ==
203
 phrase1=Ligne 1,\
204
 \
205
 Ligne 3,\
206
 Ligne 4
207
 phrase2=a,,c,d,,f,g
208
 foo=!nonempty line $phrase1
209
 bar=!nonempty item $phrase2
210
----
211
foo == Ligne 1,
212
Ligne 3,
213
Ligne 4
214
bar == a,c,d,f,g
215
== !nospace ==
216
 phrase=Maître corbeau, sur son arbre perché,\
217
 Tenait en son bec un fromage.\
218
 Maître		Renard, par l'odeur alléché,\
219
 Lui tint à peu près ce langage :
220
 foo=!nospace $phrase
221
----
222
foo == Maîtrecorbeau,sursonarbreperché,Tenaitensonbecunfromage.MaîtreRenard,parl'odeuralléché,Luitintàpeuprèscelangage:
223
== !positionof ==
224
 phrase=Maître corbeau, sur son arbre perché,\
225
 Tenait en son bec un fromage.\
226
 Maître Renard, par l'odeur alléché,\
227
 Lui tint à peu près ce langage :
228
 l=Tenait en son bec un fromage.
229
 liste=a,à,â,ä
230
 foo=!positionof char î in $phrase
231
 bar=!positionof word Maître in $phrase
232
 baz=!positionof line $l in $phrase
233
 plop=!positionof item â in $liste
234
----
235
foo == 3,71
236
bar == 1,13
237
baz == 2
238
plop == 3
239
== !product ==
240
 f=x^2
241
 foo=!product $f for x=1 to 5 step 2
242
 bar=!product $f for x=1 in 1,3,5
243
----
244
foo == 225
245
bar == 225
246
== !randchar ==
247
# cannot implement a test without replacing the generator of pseudo-random
248
# numbers by a predictable generator
249
== !randitem ==
250
# cannot implement a test without replacing the generator of pseudo-random
251
# numbers by a predictable generator
252
== !randline ==
253
# cannot implement a test without replacing the generator of pseudo-random
254
# numbers by a predictable generator
255
== !randword ==
256
# cannot implement a test without replacing the generator of pseudo-random
257
# numbers by a predictable generator
258
== !rawmath ==
259
 foo=!rawmath (x+1)(x-1)
260
 bar=!rawmath 5x^3
261
----
262
foo == (x+1)*(x-1)
263
bar == 5*x^3
264
== !rawmatrix ==
265
 foo=!rawmatrix cos(2 theta), sin(2theta); -sin(2theta), cos(2theta)
266
----
267
foo == cos(2*theta), sin(2*theta)
268
-sin(2*theta), cos(2*theta)
269
== !reaccent ==
270
foo=!reaccent a`a^a"-e'e`e^e"-i^i"-o"o^-u`u^u"-c~-A`A^A"-E'E`E^E"-I^I"-O"O^-U`U^U"-C~
271
----
272
foo == àâä-éèêë-îï-öô-ùûü-ç-ÀÂÄ-ÉÈÊË-ÎÏ-ÖÔ-ÙÛÜ-Ç
273
== !recursion ==
274
 recursion_start=1
275
 f=x*last
276
 foo=!recursion $f for x=1 to 5
277
 bar=!recursion $f for x in 1,2,3,4,5
278
----
279
foo == 120
280
bar == 120
281
== !reinput ==
282
 foo=!reinput a&nbsp;b<b>c</b>
283
----
284
foo == a&amp;nbsp;b&lt;b>c&lt;/b>
285
== !rename ==
286
# this primitive cannot be tested without runnin wims in a CGI context
287
# we shouldfind some other way to test it
288
== !replace ==
289
 foo=!replace André by Benoît in Andrée Ziegler
290
 bar=!replace internal \" by « in \"bonjour\"
291
 baz=!replace item number 2 by Monsieur in Bonjour, Madame, Éon
292
----
293
foo == Benoîte Ziegler
294
bar == «bonjour«
295
baz == Bonjour,Monsieur, Éon
296
== !select ==
297
 matrix=pair,2; impair,3; pair,4; impair, 5; pair, 6; impair, 7
298
 foo=!select $matrix where column 1 = pair
299
----
300
foo == pair,2; pair,4; pair, 6
301
== !shuffle ==
302
# cannot implement a test without replacing the generator of pseudo-random
303
# numbers by a predictable generator
304
== !singlespace ==
305
 phrase=Maître corbeau,		sur son arbre perché,\
306
 Tenait		en son bec un fromage.\
307
 Maître Renard, par	l'odeur alléché,\
308
 Lui tint à peu		près ce langage :
309
 foo=!singlespace $phrase
310
----
311
foo == Maître corbeau, sur son arbre perché, Tenait en son bec un fromage. Maître Renard, par l'odeur alléché, Lui tint à peu près ce langage :
312
== !solve ==
313
 foo=!solve sin(x)=0.5 for x=0 to 10
314
----
315
foo == 0.52359878,2.6179939,6.8067841,8.9011792
316
== !sort ==
317
 liste=6,1,3,5,4,2
318
 foo=!sort list $liste
319
----
320
foo == 1,2,3,4,5,6
321
== !sum ==
322
 f=x^2
323
 foo=!sum $f for x=1 to 5
324
----
325
foo == 55
326
== !texmath ==
327
 foo=!texmath [ 4,5;6,7]
328
 # for some reason thiscommand prepends a space to the result; is it a feature?
329
----
330
foo ==  \begin{pmatrix}4 &5\cr 6 &7 \end{pmatrix}
331
== !text common ==
332
 foo1=!text common élève and éleva
333
----
334
foo1 == élv
335
== !text common mask ==
336
 foo2=!text common élève and éleva mask 01111
337
----
338
foo2 == lv
339
== !text compare ==
340
 foo3=!text compare élève and éleva
341
-----
342
foo3 == 00101
343
== !text copy ==
344
 foo4=!text copy élève mask 00101
345
----
346
foo4 == èe
347
== !text count ==
348
 foo5=!text count e,v in élève mask 01101
349
----
350
foo5 == 1
351
== !text diff ==
352
 foo6=!text diff élève from éleva mask 11110
353
----
354
foo6 == è
355
== !text expand ==
356
 foo7=!text expand èe using 00101
357
----
358
foo7 ==   è e
359
== !text insert ==
360
 foo8=!text insert èe into éleva mask 00101
361
----
362
foo8 == élève
363
== !text interact ==
364
 itab=0123\
365
 0000\
366
 0123\
367
 0202\
368
 0321
369
 foo9=!text interact 3 and 3 table $itab
370
----
371
foo9 == 1
372
== !text mark ==
373
 foo10=!text mark èe in élève
374
----
375
foo10 == 00101
376
== !text max ==
377
 foo11=!text max 1246 and 6421
378
----
379
foo11 == 6446
380
== !text min ==
381
 foo12=!text min 1246 and 6421
382
----
383
foo12 == 1221
384
== !text occur ==
385
 foo13=!text occur abcdefghijklmnopqrstuvwxyz in élevage
386
----
387
foo13 == aeglv
388
== !text remove ==
389
 foo14=!text remove aeglv in élevage
390
----
391
foo14 == é
392
== !text reorder ==
393
 foo15=!text reorder élevage by 3,1,2
394
----
395
foo15 == eélgvae
396
== !text repeat ==
397
 foo16=!text repeat -oOo- to 25
398
----
399
foo16 == -oOo--oOo--oOo--oOo--oOo-
400
== !text reverse ==
401
 foo17=!text reverse tnavrené
402
----
403
foo17 == énervant
404
== !text select ==
405
 foo18=!text select elv in élevage
406
----
407
foo18 == leve
408
== !translate ==
409
 foo=!translate x to y in x^2-2*x+1
410
 bar=!translate internal " to ' in "bonjour", comment "ça va ?"
411
----
412
foo == y^2-2*y+1
413
bar == 'bonjour', comment 'ça va ?'
414
== !trim ==
415
# this primitive cannot be tested with the current version od the test program,
416
# since theprogram trims each line of data before its evaluation by Wims.
417
== !upper ==
418
# cannot upper accented chars ... is it a feature?
419
 foo=!upper bonjour àâä-éèêë-îï-öô-ùûü
420
----
421
foo == BONJOUR àâä-éèêë-îï-öô-ùûü
422
== !values ==
423
 f=x^2
424
 foo=!values $f for x=1 to 5
425
----
426
foo == 1,4,9,16,25
427
== !values with recursion ==
428
 f=x*last
429
 recursion_start=1
430
 foo=!values $f for x=1 to 5
431
----
432
foo == 1,2,6,24,120
433
== !varlist ==
434
 f=sin(sqrt(x^2+y^2)/100)
435
 foo=!varlist nofn $f
436
----
437
foo == x,y
438
== !word ==
439
 foo=!word 2..4 of un deux trois quatre cinq six
440
----
441
foo == deux trois quatre
442
== !wordcnt ==
443
 foo=!wordcnt un deux trois quatre cinq six
444
----
445
foo == 6