Rewrite expression code.
[pspp-builds.git] / tests / expressions / expressions.sh
1 #! /bin/sh
2
3 # Tests the expression optimizer and evaluator.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18      :
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48 activity="create expressions list"
49 sed -ne 's/#.*//;/^[    ]*$/!p' > $TEMPDIR/expr-list <<'EOF'
50
51 # Number syntax.
52 1e2 => 100.00
53 1e+2 => 100.00
54 1e-2 => 0.01
55 1e-99 => 0.00
56
57 # Test using numeric/string values as Booleans and vice-versa
58 0 AND 1 => false
59 $true AND 1 => true
60 1 OR $false => true
61 1 OR $sysmis => true
62 2 OR $sysmis => sysmis
63 2 AND $sysmis => false
64 'string' AND $sysmis => error
65 0 AND $sysmis => false
66 (1>2) + 1 => 1.00
67 $true + $false => 1.00
68
69 # Addition and subtraction.
70 1 + 2 => 3.00
71 1 + $true => 2.00
72 $sysmis + 1 => sysmis
73 7676 + $sysmis => sysmis
74 ('foo') + 5 => error
75 ('foo') + ('bar') => error      # Arithmetic concatenation requires CONCAT.
76 'foo' + 'bar' => "foobar"       # Lexical concatentation succeeds.
77 1 +3 - 2 +4 -5 => 1.00
78 1 - $true => 0.00
79 $true - 4/3 => -0.33
80 'string' - 1e10 => error
81 9.5 - '' => error
82 1 - 2 => -1.00
83 52 -23 => 29.00 
84
85 # Multiplication and division
86 5 * 10 => 50.00
87 10 * $true => 10.00
88 $true * 5 => 5.00
89 1.5 * $true => 1.50
90 5 * $sysmis => sysmis
91 $sysmis * 15 => sysmis
92 2 * 5 / 10 => 1.00
93 1 / 2 => 0.50
94 2 / 5 => 0.40
95 12 / 3 / 2 => 2.00
96
97 # Exponentiation.
98 2**8 => 256.00
99 (2**3)**4 => 4096.00    # Irritating, but compatible.
100 2**3**4 => 4096.00
101
102 # Unary minus.
103 2+-3 => -1.00
104 2*-3 => -6.00
105 -3**2 => -9.00
106 (-3)**2 => 9.00
107 2**-1 => 0.50
108 0**0 => sysmis
109 0**-1 => sysmis
110 (-3)**1.5 => sysmis
111
112 # AND truth table.
113 $false AND $false => false
114 $false AND $true => false
115 $false AND $sysmis => false
116 $true AND $false => false
117 $true AND $true => true
118 $true AND $sysmis => sysmis
119 $sysmis AND $false => false
120 $sysmis AND $true => sysmis
121 $sysmis AND $sysmis => sysmis
122 $false & $false => false
123 $false & $true => false
124 $false & $sysmis => false
125 $true & $false => false
126 $true & $true => true
127 $true & $sysmis => sysmis
128 $sysmis & $false => false
129 $sysmis & $true => sysmis
130 $sysmis & $sysmis => sysmis
131
132 # OR truth table.
133 $false OR $false => false
134 $false OR $true => true
135 $false OR $sysmis => sysmis
136 $true OR $false => true
137 $true OR $true => true
138 $true OR $sysmis => true
139 $sysmis OR $false => sysmis
140 $sysmis OR $true => true
141 $sysmis OR $sysmis => sysmis
142 $false | $false => false
143 $false | $true => true
144 $false | $sysmis => sysmis
145 $true | $false => true
146 $true | $true => true
147 $true | $sysmis => true
148 $sysmis | $false => sysmis
149 $sysmis | $true => true
150 $sysmis | $sysmis => sysmis
151
152 # NOT truth table.
153 not $false => true
154 not 0 => true
155 not 2.5 => true
156 not $true => false
157 not 1 => false
158 not $sysmis => sysmis
159 ~ $false => true
160 ~ 0 => true
161 ~ 2.5 => true
162 ~ $true => false
163 ~ 1 => false
164 ~ $sysmis => sysmis
165
166 # Relational operators.
167 1 eq 1 => true
168 1 = 1 => true
169 1 eq 2 => false
170 2 = 3 => false
171 1 eq 'foobar' => error
172 5 eq 'foobar' => error
173 'baz' = 10 => error
174 'quux' = 5.55 => error
175 'foobar' = 'foobar' => true
176 'quux' = 'bar' => false
177 'bar   ' = 'bar' => true
178 'asdf         ' = 'asdf  ' => true
179 'asdfj   ' = 'asdf' => false
180 1 + 2 = 3 => true               # Check precedence.
181 1 >= 2 = 2 ge 3 => false        # Check precedence.
182 3 ne 2 ~= 1 => false            # Mathematically true.
183 3 > 2 > 1 => false              # Mathematically true.
184
185 1 <= 2 => true
186 2.5 <= 1.5 => false
187 1 le 2 => true
188 2 <= 2 => true
189 2 le 2 => true
190 2 < = 2 => error        # Make sure <= token can't be split.
191 1 <= 'foobar' => error
192 5 <= 'foobar' => error
193 'baz' <= 10 => error
194 'quux' <= 5.55 => error
195 '0123' <= '0123' => true
196 '0123' <= '0124' => true
197 '0124' le '0123' => false
198 '0123  ' <= '0123' => true
199 '0123' le '0123  ' => true
200
201 1 < 2 => true
202 2.5 < 1.5 => false
203 3.5 lt 4 => true
204 4 lt 3.5 => false
205 1 lt 'foobar' => error
206 5 lt 'foobar' => error
207 'baz' < 10 => error
208 'quux' < 5.55 => error
209 '0123' lt '0123' => false
210 '0123' < '0124' => true
211 '0124' lt '0123' => false
212 '0123  ' < '0123' => false
213 '0123' lt '0123  ' => false
214
215 1 >= 2 => false
216 2.5 >= 1.5 => true
217 1 ge 2 => false
218 2 >= 2 => true
219 2 ge 2 => true
220 2 > = 2 => error        # Make sure >= token can't be split.
221 1 >= 'foobar' => error
222 5 ge 'foobar' => error
223 'baz' ge 10 => error
224 'quux' >= 5.55 => error
225 '0123' ge '0123' => true
226 '0123' >= '0124' => false
227 '0124' >= '0123' => true
228 '0123  ' ge '0123' => true
229 '0123' >= '0123  ' => true
230
231 1 > 2 => false
232 2.5 > 1.5 => true
233 3.5 gt 4 => false
234 4 gt 3.5 => true
235 1 gt 'foobar' => error
236 5 gt 'foobar' => error
237 'baz' > 10 => error
238 'quux' > 5.55 => error
239 '0123' gt '0123' => false
240 '0123' > '0124' => false
241 '0124' gt '0123' => true
242 '0123  ' > '0123' => false
243 '0123' gt '0123  ' => false
244
245 1 ne 1 => false
246 1 ~= 1 => false
247 1 <> 2 => true
248 2 ne 3 => true
249 1 ~= 'foobar' => error
250 5 <> 'foobar' => error
251 'baz' ne 10 => error
252 'quux' ~= 5.55 => error
253 'foobar' <> 'foobar' => false
254 'quux' ne 'bar' => true
255 'bar   ' <> 'bar' => false
256 'asdf         ' ~= 'asdf  ' => false
257 'asdfj   ' ne 'asdf' => true
258 1 < > 1 => error        # <> token can't be split
259 1 ~ = 1 => error        # ~= token can't be split
260
261 exp(10) => 22026.47
262 exp('x') => error
263
264 lg10(500) => 2.70
265 lg10('x') => error
266
267 ln(10) => 2.30
268 ln('x') => error
269
270 sqrt(500) => 22.36
271 sqrt('x') => error
272
273 abs(-10.5) => 10.50
274 abs(-55.79) => 55.79
275 abs(22) => 22.00
276 abs(0) => 0.00
277
278 mod(55.5, 2) => 1.50
279 mod(-55.5, 2) => -1.50
280 mod(55.5, -2) => 1.50
281 mod(-55.5, -2) => -1.50
282 mod('a', 2) => error
283 mod(2, 'a') => error
284 mod('a', 'b') => error
285
286 mod10(55.5) => 5.50
287 mod10(-55.5) => -5.50
288 mod10('x') => error
289
290 rnd(5.4) => 5.00
291 rnd(5.6) => 6.00
292 rnd(-5.4) => -5.00
293 rnd(-5.6) => -6.00
294 rnd('x') => error
295
296 trunc(1.2) => 1.00
297 trunc(1.9) => 1.00
298 trunc(-1.2) => -1.00
299 trunc(-1.9) => -1.00
300 trunc('x') => error
301
302 acos(.5) / 3.14159 * 180 => 60.00
303 arcos(.75) / 3.14159 * 180 => 41.41
304 arcos(-.5) / 3.14159 * 180 => 120.00
305 acos(-.75) / 3.14159 * 180 => 138.59
306 acos(-1) / 3.14159 * 180 => 180.00
307 arcos(1) / 3.14159 * 180 => 0.00
308 acos(-1.01) => sysmis
309 arcos(1.01) => sysmis
310 acos('x') => error
311
312 arsin(.5) / 3.14159 * 180 => 30.00
313 asin(.25) / 3.14159 * 180 => 14.48
314 arsin(-.5) / 3.14159 * 180 => -30.00
315 asin(-.25) / 3.14159 * 180 => -14.48
316 arsin(-1.01) => sysmis
317 asin(1.01) => sysmis
318 arsin('x') => error
319
320 artan(1) / 3.14159 * 180 => 45.00
321 atan(10) / 3.14159 * 180 => 84.29
322 artan(-1) / 3.14159 * 180 => -45.00
323 atan(-10) / 3.14159 * 180 => -84.29
324 artan('x') => error
325
326 cos(60 / 180 * 3.14159) => 0.50
327 cos(45 / 180 * 3.14159) => 0.71
328 cos(30 / 180 * 3.14159) => 0.87
329 cos(15 / 180 * 3.14159) => 0.97
330 cos(-60 / 180 * 3.14159) => 0.50
331 cos(-45 / 180 * 3.14159) => 0.71
332 cos(-30 / 180 * 3.14159) => 0.87
333 cos(-15 / 180 * 3.14159) => 0.97
334 cos(123 / 180 * 3.14159) => -0.54
335 cos(321 / 180 * 3.14159) => 0.78
336 cos('x') => error
337
338 sin(60 / 180 * 3.14159) => 0.87
339 sin(45 / 180 * 3.14159) => 0.71
340 sin(30 / 180 * 3.14159) => 0.50
341 sin(15 / 180 * 3.14159) => 0.26
342 sin(-60 / 180 * 3.14159) => -0.87
343 sin(-45 / 180 * 3.14159) => -0.71
344 sin(-30 / 180 * 3.14159) => -0.50
345 sin(-15 / 180 * 3.14159) => -0.26
346 sin(123 / 180 * 3.14159) => 0.84
347 sin(321 / 180 * 3.14159) => -0.63
348 sin('x') => error
349
350 tan(60 / 180 * 3.14159) => 1.73
351 tan(45 / 180 * 3.14159) => 1.00
352 tan(30 / 180 * 3.14159) => 0.58
353 tan(15 / 180 * 3.14159) => 0.27
354 tan(-60 / 180 * 3.14159) => -1.73
355 tan(-45 / 180 * 3.14159) => -1.00
356 tan(-30 / 180 * 3.14159) => -0.58
357 tan(-15 / 180 * 3.14159) => -0.27
358 tan(123 / 180 * 3.14159) => -1.54
359 tan(321 / 180 * 3.14159) => -0.81
360 tan('x') => error
361
362 # FIXME: a variable name as the argument to SYSMIS is a special case
363 # that we don't yet test.  We also can't test VALUE this way.
364 missing(10) => false
365 missing($sysmis) => true
366 missing(asin(1.01)) => true
367 missing(asin(.5)) => false
368 missing('    ') => error
369 nmiss($sysmis) => 1.00
370 nmiss(0) => 0.00
371 nmiss($sysmis, $sysmis, $sysmis) => 3.00
372 nmiss(1, 2, 3, 4) => 0.00
373 nmiss(1, $sysmis, $sysmis, 2, 2, $sysmis, $sysmis, 3, 4) => 4.00
374 nvalid($sysmis) => 0.00
375 nvalid(0) => 1.00
376 nvalid($sysmis, $sysmis, $sysmis) => 0.00
377 nvalid(1, 2, 3, 4) => 4.00
378 nvalid(1, $sysmis, $sysmis, 2, 2, $sysmis, $sysmis, 3, 4) => 5.00
379 sysmis(10) => false
380 sysmis($sysmis) => true
381 sysmis(asin(1.01)) => true
382 sysmis(asin(.5)) => false
383 sysmis('    ') => error
384
385 any($sysmis, 1, $sysmis, 3) => sysmis
386 any(1, 1, 2, 3) => true
387 any(1, $true, 2, 3) => true
388 any(1, $false, 2, 3) => false
389 any(2, 1, 2, 3) => true
390 any(3, 1, 2, 3) => true
391 any(5, 1, 2, 3) => false
392 any(1, 1, 1, 1) => true
393 any($sysmis, 1, 1, 1) => sysmis
394 any(1, $sysmis, $sysmis, $sysmis) => sysmis
395 any($sysmis, $sysmis, $sysmis, $sysmis) => sysmis
396 any(1) => error
397 any('1', 2, 3, 4) => error
398 any(1, '2', 3, 4) => error
399 any(1, 2, '3', 4) => error
400 any(1, 2, 3, '4') => error
401
402 any('', 'a', '', 'c') => true
403 any('a', 'a', 'b', 'c') => true
404 any('b', 'a', 'b', 'c') => true
405 any('c', 'a', 'b', 'c') => true
406 any('e', 'a', 'b', 'c') => false
407 any('a', 'a', 'a', 'a') => true
408 any('', 'a', 'a', 'a') => false
409 any('a', '', '', '') => false
410 any('a') => error
411 any('a', 'a  ', 'b', 'c') => true
412 any('b   ', 'a', 'b', 'c') => true
413 any('c   ', 'a', 'b', 'c     ') => true
414 any(a, 'b', 'c', 'd') => error
415 any('a', b, 'c', 'd') => error
416 any('a', 'b', c, 'd') => error
417 any('a', 'b', 'c', d) => error
418
419 range(5, 1, 10) => true
420 range(1, 1, 10) => true
421 range(10, 1, 10) => true
422 range(-1, 1, 10) => false
423 range(12, 1, 10) => false
424 range($sysmis, 1, 10) => sysmis
425 range(5, 1, $sysmis) => sysmis
426 range(5, $sysmis, 10) => sysmis
427 range($sysmis, $sysmis, 10) => sysmis 
428 range($sysmis, 1, $sysmis) => sysmis
429 range($sysmis, $sysmis, $sysmis) => sysmis
430 range(0, 1, 8, 10, 18) => false
431 range(1, 1, 8, 10, 18) => true
432 range(6, 1, 8, 10, 18) => true
433 range(8, 1, 8, 10, 18) => true
434 range(9, 1, 8, 10, 18) => false
435 range(10, 1, 8, 10, 18) => true
436 range(13, 1, 8, 10, 18) => true
437 range(16, 1, 8, 10, 18) => true
438 range(18, 1, 8, 10, 18) => true
439 range(20, 1, 8, 10, 18) => false
440 range(1) => error
441 range(1, 2) => error
442 range(1, 2, 3, 4) => error
443 range(1, 2, 3, 4, 5, 6) => error
444 range('1', 2, 3) => error
445 range(1, '2', 3) => error
446 range(1, 2, '3') => error
447
448 range('123', '111', '888') => true
449 range('111', '111', '888') => true
450 range('888', '111', '888') => true
451 range('110', '111', '888') => false
452 range('889', '111', '888') => false
453 range('000', '111', '888') => false
454 range('999', '111', '888') => false
455 range('123   ', '111', '888') => true
456 range('123', '111   ', '888') => true
457 range('123', '111', '888   ') => true
458 range('123', '111    ', '888   ') => true
459 range('00', '01', '08', '10', '18') => false
460 range('01', '01', '08', '10', '18') => true
461 range('06', '01', '08', '10', '18') => true
462 range('08', '01', '08', '10', '18') => true
463 range('09', '01', '08', '10', '18') => false
464 range('10', '01', '08', '10', '18') => true
465 range('15', '01', '08', '10', '18') => true
466 range('18', '01', '08', '10', '18') => true
467 range('19', '01', '08', '10', '18') => false
468 range('1') => error
469 range('1', '2') => error
470 range('1', '2', '3', '4') => error
471 range('1', '2', '3', '4', '5', '6') => error
472 range(1, '2', '3') => error
473 range('1', 2, '3') => error
474 range('1', '2', 3) => error
475
476 cfvar(1, 2, 3, 4, 5) => 0.53
477 cfvar(1, $sysmis, 2, 3, $sysmis, 4, 5) => 0.53
478 cfvar(1, 2) => 0.47
479 cfvar(1) => error
480 cfvar(1, $sysmis) => sysmis
481 cfvar(1, 2, 3, $sysmis) => 0.50
482 cfvar.4(1, 2, 3, $sysmis) => sysmis
483 cfvar.4(1, 2, 3) => error
484 cfvar('x') => error
485 cfvar('x', 1, 2, 3) => error
486
487 max(1, 2, 3, 4, 5) => 5.00
488 max(1, $sysmis, 2, 3, $sysmis, 4, 5) => 5.00
489 max(1, 2) => 2.00
490 max() => error
491 max(1) => 1.00
492 max(1, $sysmis) => 1.00
493 max(1, 2, 3, $sysmis) => 3.00
494 max.4(1, 2, 3, $sysmis) => sysmis
495 max.4(1, 2, 3) => error
496
497 max("2", "3", "5", "1", "4") => "5"
498 max("1", "2") => "2"
499 max("1") => "1"
500
501 mean(1, 2, 3, 4, 5) => 3.00
502 mean(1, $sysmis, 2, 3, $sysmis, 4, 5) => 3.00
503 mean(1, 2) => 1.50
504 mean() => error
505 mean(1) => 1.00
506 mean(1, $sysmis) => 1.00
507 mean(1, 2, 3, $sysmis) => 2.00
508 mean.4(1, 2, 3, $sysmis) => sysmis
509 mean.4(1, 2, 3) => error
510
511 min(1, 2, 3, 4, 5) => 1.00
512 min(1, $sysmis, 2, 3, $sysmis, 4, 5) => 1.00
513 min(1, 2) => 1.00
514 min() => error
515 min(1) => 1.00
516 min(1, $sysmis) => 1.00
517 min(1, 2, 3, $sysmis) => 1.00
518 min.4(1, 2, 3, $sysmis) => sysmis
519 min.4(1, 2, 3) => error
520
521 min("2", "3", "5", "1", "4") => "1"
522 min("1", "2") => "1"
523 min("1") => "1"
524
525 sd(1, 2, 3, 4, 5) => 1.58
526 sd(1, $sysmis, 2, 3, $sysmis, 4, 5) => 1.58
527 sd(1, 2) => 0.71
528 sd(1) => error
529 sd(1, $sysmis) => sysmis
530 sd(1, 2, 3, $sysmis) => 1.00
531 sd.4(1, 2, 3, $sysmis) => sysmis
532 sd.4(1, 2, 3) => error
533 sd('x') => error
534 sd('x', 1, 2, 3) => error
535
536 sum(1, 2, 3, 4, 5) => 15.00
537 sum(1, $sysmis, 2, 3, $sysmis, 4, 5) => 15.00
538 sum(1, 2) => 3.00
539 sum() => error
540 sum(1) => 1.00
541 sum(1, $sysmis) => 1.00
542 sum(1, 2, 3, $sysmis) => 6.00
543 sum.4(1, 2, 3, $sysmis) => sysmis
544 sum.4(1, 2, 3) => error
545
546 variance(1, 2, 3, 4, 5) => 2.50
547 variance(1, $sysmis, 2, 3, $sysmis, 4, 5) => 2.50
548 variance(1, 2) => 0.50
549 variance(1) => error
550 variance(1, $sysmis) => sysmis
551 variance(1, 2, 3, $sysmis) => 1.00
552 variance.4(1, 2, 3, $sysmis) => sysmis
553 variance.4(1, 2, 3) => error
554 variance('x') => error
555 variance('x', 1, 2, 3) => error
556
557 concat('') => ""
558 concat('a', 'b') => "ab"
559 concat('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') => "abcdefgh"
560 concat('abcdefgh', 'ijklmnopq') => "abcdefghijklmnopq"
561 concat('a', 1) => error
562 concat(1, 2) => error
563
564 index('abcbcde', 'bc') => 2.00
565 index('abcbcde', 'bcd') => 4.00
566 index('abcbcde', 'bcbc') => 2.00
567 index('abcdefgh', 'abc') => 1.00
568 index('abcdefgh', 'bcd') => 2.00
569 index('abcdefgh', 'cde') => 3.00
570 index('abcdefgh', 'def') => 4.00
571 index('abcdefgh', 'efg') => 5.00
572 index('abcdefgh', 'fgh') => 6.00
573 index('abcdefgh', 'fghi') => 0.00
574 index('abcdefgh', 'x') => 0.00
575 index('abcdefgh', 'abch') => 0.00
576 index('banana', 'na') => 3.00
577 index('banana', 'ana') => 2.00
578 index('', 'x') => 0.00
579 index('', '') => sysmis
580 index('abcdefgh', '') => sysmis
581 index('abcdefgh', 'alkjsfdjlskalkjfa') => 0.00
582
583 index('abcbcde', 'bc', 1) => 2.00
584 index('abcbcde', 'dc', 1) => 3.00
585 index('abcbcde', 'abc', 1) => 1.00
586 index('abcbcde', 'bc', 2) => 2.00
587 index('abcbcde', 'dc', 2) => 0.00
588 index('abcbcde', 'abc', 1) => 1.00
589 index('abcbcde', 'bccb', 2) => 2.00
590 index('abcbcde', 'bcbc', 2) => 2.00
591 index('abcbcde', 'bcbc', $sysmis) => sysmis
592
593 rindex('abcbcde', 'bc') => 4.00
594 rindex('abcbcde', 'bcd') => 4.00
595 rindex('abcbcde', 'bcbc') => 2.00
596 rindex('abcdefgh', 'abc') => 1.00
597 rindex('abcdefgh', 'bcd') => 2.00
598 rindex('abcdefgh', 'cde') => 3.00
599 rindex('abcdefgh', 'def') => 4.00
600 rindex('abcdefgh', 'efg') => 5.00
601 rindex('abcdefgh', 'fgh') => 6.00
602 rindex('abcdefgh', 'fghi') => 0.00
603 rindex('abcdefgh', 'x') => 0.00
604 rindex('abcdefgh', 'abch') => 0.00
605 rindex('banana', 'na') => 5.00
606 rindex('banana', 'ana') => 4.00
607 rindex('', 'x') => 0.00
608 rindex('', '') => sysmis
609 rindex('abcdefgh', '') => sysmis
610 rindex('abcdefgh', 'alkjsfdjlskalkjfa') => 0.00
611
612 rindex('abcbcde', 'bc', 1) => 5.00
613 rindex('abcbcde', 'dc', 1) => 6.00
614 rindex('abcbcde', 'abc', 1) => 5.00
615 rindex('abcbcde', 'bc', 2) => 4.00
616 rindex('abcbcde', 'dc', 2) => 0.00
617 rindex('abcbcde', 'abc', 1) => 5.00
618 rindex('abcbcde', 'bccb', 2) => 4.00
619 rindex('abcbcde', 'bcbc', 2) => 4.00
620 rindex('abcbcde', 'bcbc', $sysmis) => sysmis
621 rindex('abcbcde', 'bcbcg', 2) => sysmis
622 rindex('abcbcde', 'bcbcg', $sysmis) => sysmis
623 rindex('abcbcde', 'bcbcg', 'x') => error
624 rindex(1, 'bcdfkjl', 2) => error
625 rindex('aksj', 2, 2) => error
626 rindex(1, 2, 3) => error
627 rindex(1, 2, '3') => error
628
629 length('') => 0.00
630 length('a') => 1.00
631 length('xy') => 2.00
632 length('adsf    ') => 8.00
633 length('abcdefghijkl') => 12.00
634 length(0) => error
635 length($sysmis) => error
636
637 lower('ABCDEFGHIJKLMNOPQRSTUVWXYZ!@%&*(089') => "abcdefghijklmnopqrstuvwxyz!@%&*(089"
638 lower('') => ""
639 lower(1) => error
640
641 lpad('abc', -1) => ""
642 lpad('abc', 0) => "abc"
643 lpad('abc', 2) => "abc"
644 lpad('abc', 3) => "abc"
645 lpad('abc', 10) => "       abc"
646 lpad('abc', 256) => ""
647 lpad('abc', $sysmis) => ""
648 lpad('abc', -1, '*') => ""
649 lpad('abc', 0, '*') => "abc"
650 lpad('abc', 2, '*') => "abc"
651 lpad('abc', 3, '*') => "abc"
652 lpad('abc', 10, '*') => "*******abc"
653 lpad('abc', 256, '*') => ""
654 lpad('abc', $sysmis, '*') => ""
655 lpad('abc', $sysmis, '') => ""
656 lpad('abc', $sysmis, 'xy') => ""
657 lpad(0, 10) => error
658 lpad('abc', 'def') => error
659 lpad(0, 10, ' ') => error
660 lpad('abc', 'def', ' ') => error
661 lpad('x', 5, 0) => error
662 lpad('x', 5, 2) => error
663
664 number("123", f3.0) => 123.00
665 number(" 123", f3.0) => 12.00
666 number("123", f3.1) => 12.30
667 number("   ", f3.1) => sysmis
668 number("123", cca1.2) => error  # CCA is not an input format
669
670 ltrim('   abc') => "abc"
671 rtrim('   abc   ') => "   abc"
672 ltrim('abc') => "abc"
673 ltrim(' abc') => "      abc"
674 ltrim('    ') => ""
675 ltrim('') => ""
676 ltrim(8) => error
677 ltrim('***abc', '*') => "abc"
678 ltrim('abc', '*') => "abc"
679 ltrim('*abc', '*') => "abc"
680 ltrim('', '*') => ""
681 ltrim(8, '*') => error
682 ltrim(' x', 8) => error
683 ltrim(8, 9) => error
684
685 rpad('abc', -1) => ""
686 rpad('abc', 0) => "abc"
687 rpad('abc', 2) => "abc"
688 rpad('abc', 3) => "abc"
689 rpad('abc', 10) => "abc       "
690 rpad('abc', 256) => ""
691 rpad('abc', $sysmis) => ""
692 rpad('abc', -1, '*') => ""
693 rpad('abc', 0, '*') => "abc"
694 rpad('abc', 2, '*') => "abc"
695 rpad('abc', 3, '*') => "abc"
696 rpad('abc', 10, '*') => "abc*******"
697 rpad('abc', 256, '*') => ""
698 rpad('abc', $sysmis, '*') => ""
699 rpad('abc', $sysmis, '') => ""
700 rpad('abc', $sysmis, 'xy') => ""
701 rpad(0, 10) => error
702 rpad('abc', 'def') => error
703 rpad(0, 10, ' ') => error
704 rpad('abc', 'def', ' ') => error
705 rpad('x', 5, 0) => error
706 rpad('x', 5, 2) => error
707
708 rtrim('abc   ') => "abc"
709 rtrim('   abc   ') => "   abc"
710 rtrim('abc') => "abc"
711 rtrim('abc      ') => "abc      "
712 rtrim('    ') => ""
713 rtrim('') => ""
714 rtrim(8) => error
715 rtrim('abc***', '*') => "abc"
716 rtrim('abc', '*') => "abc"
717 rtrim('abc*', '*') => "abc"
718 rtrim('', '*') => ""
719 rtrim(8, '*') => error
720 rtrim(' x', 8) => error
721 rtrim(8, 9) => error
722
723 string(123.56, f5.1) => "123.6"
724 string($sysmis, f5.1) => "   . "
725 string("abc", A5) => error
726 string(123, e1) => error        # E has a minimum width of 6 on output.
727 string(123, e6.0) => " 1E+02"
728
729 substr('abcdefgh', -5) => ""
730 substr('abcdefgh', 0) => ""
731 substr('abcdefgh', 1) => "abcdefgh"
732 substr('abcdefgh', 3) => "cdefgh"
733 substr('abcdefgh', 5) => "efgh"
734 substr('abcdefgh', 6) => "fgh"
735 substr('abcdefgh', 7) => "gh"
736 substr('abcdefgh', 8) => "h"
737 substr('abcdefgh', 9) => ""
738 substr('abcdefgh', 10) => ""
739 substr('abcdefgh', 20) => ""
740 substr('abcdefgh', $sysmis) => ""
741 substr(0, 10) => error
742 substr('abcd', 'abc') => error
743 substr(0, 'abc') => error
744
745 substr('abcdefgh', 0, 0) => ""
746 substr('abcdefgh', 3, 0) => ""
747 substr('abcdefgh', 5, 0) => ""
748 substr('abcdefgh', 9, 0) => ""
749 substr('abcdefgh', 0, 1) => ""
750 substr('abcdefgh', 0, 5) => ""
751 substr('abcdefgh', 1, 8) => "abcdefgh"
752 substr('abcdefgh', 1, 10) => "abcdefgh"
753 substr('abcdefgh', 1, 20) => "abcdefgh"
754 substr('abcdefgh', 3, 4) => "cdef"
755 substr('abcdefgh', 5, 2) => "ef"
756 substr('abcdefgh', 6, 1) => "f"
757 substr('abcdefgh', 7, 10) => "gh"
758 substr('abcdefgh', 8, 1) => "h"
759 substr('abcdefgh', 8, 2) => "h"
760 substr('abcdefgh', 9, 11) => ""
761 substr('abcdefgh', 10, 52) => ""
762 substr('abcdefgh', 20, 1) => ""
763 substr('abcdefgh', $sysmis, 2) => ""
764 substr('abcdefgh', 9, $sysmis) => ""
765 substr('abcdefgh', $sysmis, $sysmis) => ""
766 substr('abc', 1, 'x') => error
767 substr(0, 10, 1) => error
768 substr(0, 10, 'x') => error
769 substr('abcd', 'abc', 0) => error
770 substr('abcd', 'abc', 'j') => error
771 substr(0, 'abc', 4) => error
772 substr(0, 'abc', 'k') => error
773
774 upcase('abcdefghijklmnopqrstuvwxyz!@%&*(089') => "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@%&*(089"
775 upcase('') => ""
776 upcase(1) => error
777
778 time.days(1) => 86400.00
779 time.days(-1) => -86400.00
780 time.days(0.5) => 43200.00
781 time.days('x') => error
782 time.days($sysmis) => sysmis
783
784 time.hms(4,50,38) => 17438.00
785 time.hms(12,31,35) => 45095.00
786 time.hms(12,47,53) => 46073.00
787 time.hms(1,26,0) => 5160.00
788 time.hms(20,58,11) => 75491.00
789 time.hms(7,36,5) => 27365.00
790 time.hms(15,43,49) => 56629.00
791 time.hms(4,25,9) => 15909.00
792 time.hms(6,49,27) => 24567.00
793 time.hms(2,57,52) => 10672.00
794 time.hms(16,45,44) => 60344.00
795 time.hms(21,30,57) => 77457.00
796 time.hms(22,30,4) => 81004.00
797 time.hms(1,56,51) => 7011.00
798 time.hms(5, 6, 7) => 18367.00
799 time.hms(5, 6, 0) => 18360.00
800 time.hms(5, 0, 7) => 18007.00
801 time.hms(0, 6, 7) => 367.00
802 time.hms(-5, 6, -7) => sysmis
803 time.hms(-5, 5, -7) => sysmis
804 time.hms($sysmis, 6, 7) => sysmis
805 time.hms(5, $sysmis, 7) => sysmis
806 time.hms(5, $sysmis, 7) => sysmis
807 time.hms($sysmis, $sysmis, 7) => sysmis
808 time.hms(5, $sysmis, $sysmis) => sysmis
809 time.hms($sysmis, $sysmis, 7) => sysmis
810 time.hms($sysmis, $sysmis, $sysmis) => sysmis
811
812 ctime.days(106272) => 1.23
813 ctime.hours(106272) => 29.52
814 ctime.minutes(106272) => 1771.20
815 ctime.seconds(106272) => 106272.00
816 ctime.days(-106272) => -1.23
817 ctime.hours(-106272) => -29.52
818 ctime.minutes(-106272) => -1771.20
819 ctime.seconds(-106272) => -106272.00
820 ctime.days($sysmis) => sysmis
821 ctime.hours($sysmis) => sysmis
822 ctime.minutes($sysmis) => sysmis
823 ctime.seconds($sysmis) => sysmis
824 ctime.days('a') => error
825 ctime.hours('b') => error
826 ctime.minutes('c') => error
827 ctime.seconds('d') => error
828
829 ctime.days(date.dmy(15,10,1582)) => 1.00
830 ctime.days(date.dmy(6,9,1719)) => 50000.00
831 ctime.days(date.dmy(24,1,1583)) => 102.00
832 ctime.days(date.dmy(14,12,1585)) => 1157.00
833 ctime.days(date.dmy(26,11,1621)) => 14288.00
834 ctime.days(date.dmy(25,12,1821)) => 87365.00
835 ctime.days(date.dmy(3,12,1882)) => 109623.00
836 ctime.days(date.dmy(6,4,2002)) => 153211.00
837 ctime.days(date.dmy(19,12,1999)) => 152372.00
838 ctime.days(date.dmy(1,10,1978)) => 144623.00
839 ctime.days(date.dmy(0,10,1978)) => 144622.00
840 ctime.days(date.dmy(32,10,1978)) => sysmis
841 ctime.days(date.dmy(31,0,1978)) => 144349.00
842 ctime.days(date.dmy(31,13,1978)) => 144745.00
843 ctime.days(date.dmy($sysmis,10,1978)) => sysmis
844 ctime.days(date.dmy(31,$sysmis,1978)) => sysmis
845 ctime.days(date.dmy(31,10,$sysmis)) => sysmis
846 ctime.days(date.dmy($sysmis,$sysmis,1978)) => sysmis
847 ctime.days(date.dmy(31,$sysmis,$sysmis)) => sysmis
848 ctime.days(date.dmy($sysmis,10,$sysmis)) => sysmis
849 ctime.days(date.dmy($sysmis,$sysmis,$sysmis)) => sysmis
850 date.dmy('a',1,2) => error
851 date.dmy(1,'a',2) => error
852 date.dmy(1,2,'a') => error
853 # FIXME: check out-of-range and nearly out-of-range values
854
855 yrmoda(1582,10,15) => 1.00
856 yrmoda(1719,9,6) => 50000.00
857 yrmoda(1583,1,24) => 102.00
858 yrmoda(1585,12,14) => 1157.00
859 yrmoda(1621,11,26) => 14288.00
860 yrmoda(1821,12,25) => 87365.00
861 yrmoda(1882,12,3) => 109623.00
862 yrmoda(2002,4,6) => 153211.00
863 yrmoda(1999,12,19) => 152372.00
864 yrmoda(1978,10,1) => 144623.00
865 yrmoda(1978,10,0) => 144622.00
866 yrmoda(1978,10,32) => sysmis
867 yrmoda(1978,0,31) => 144349.00
868 yrmoda(1978,13,31) => 144745.00
869 yrmoda(1978,10,$sysmis) => sysmis
870 yrmoda(1978,$sysmis,31) => sysmis
871 yrmoda($sysmis,10,31) => sysmis
872 yrmoda(1978,$sysmis,$sysmis) => sysmis
873 yrmoda($sysmis,$sysmis,31) => sysmis
874 yrmoda($sysmis,10,$sysmis) => sysmis
875 yrmoda($sysmis,$sysmis,$sysmis) => sysmis
876 yrmoda('a',1,2) => error
877 yrmoda(1,'a',2) => error
878 yrmoda(1,2,'a') => error
879 # FIXME: check out-of-range and nearly out-of-range values
880
881 ctime.days(date.mdy(6,10,1648)) + 577735 => 601716.00
882 ctime.days(date.mdy(6,30,1680)) + 577735 => 613424.00
883 ctime.days(date.mdy(7,24,1716)) + 577735 => 626596.00
884 ctime.days(date.mdy(6,19,1768)) + 577735 => 645554.00
885 ctime.days(date.mdy(8,2,1819)) + 577735 => 664224.00
886 ctime.days(date.mdy(3,27,1839)) + 577735 => 671401.00
887 ctime.days(date.mdy(4,19,1903)) + 577735 => 694799.00
888 ctime.days(date.mdy(8,25,1929)) + 577735 => 704424.00
889 ctime.days(date.mdy(9,29,1941)) + 577735 => 708842.00
890 ctime.days(date.mdy(4,19,1943)) + 577735 => 709409.00
891 ctime.days(date.mdy(10,7,1943)) + 577735 => 709580.00
892 ctime.days(date.mdy(3,17,1992)) + 577735 => 727274.00
893 ctime.days(date.mdy(2,25,1996)) + 577735 => 728714.00
894 ctime.days(date.mdy(11,10,2038)) + 577735 => 744313.00
895 ctime.days(date.mdy(7,18,2094)) + 577735 => 764652.00
896 # FIXME: check out-of-range and nearly out-of-range values
897
898 ctime.days(date.mdy(10,15,1582)) => 1.00
899 ctime.days(date.mdy(9,6,1719)) => 50000.00
900 ctime.days(date.mdy(1,24,1583)) => 102.00
901 ctime.days(date.mdy(12,14,1585)) => 1157.00
902 ctime.days(date.mdy(11,26,1621)) => 14288.00
903 ctime.days(date.mdy(12,25,1821)) => 87365.00
904 ctime.days(date.mdy(12,3,1882)) => 109623.00
905 ctime.days(date.mdy(4,6,2002)) => 153211.00
906 ctime.days(date.mdy(12,19,1999)) => 152372.00
907 ctime.days(date.mdy(10,1,1978)) => 144623.00
908 ctime.days(date.mdy(10,0,1978)) => 144622.00
909 ctime.days(date.mdy(10,32,1978)) => sysmis
910 ctime.days(date.mdy(0,31,1978)) => 144349.00
911 ctime.days(date.mdy(13,31,1978)) => 144745.00
912 ctime.days(date.mdy(10,$sysmis,1978)) => sysmis
913 ctime.days(date.mdy($sysmis,31,1978)) => sysmis
914 ctime.days(date.mdy(10,31,$sysmis)) => sysmis
915 ctime.days(date.mdy($sysmis,$sysmis,1978)) => sysmis
916 ctime.days(date.mdy($sysmis,31,$sysmis)) => sysmis
917 ctime.days(date.mdy(10,$sysmis,$sysmis)) => sysmis
918 ctime.days(date.mdy($sysmis,$sysmis,$sysmis)) => sysmis
919 date.mdy('a',1,2) => error
920 date.mdy(1,'a',2) => error
921 date.mdy(1,2,'a') => error
922 ctime.days(date.mdy(0,0,0)) => 152353.00
923 ctime.days(date.mdy(0,0,999)) => sysmis
924 date.mdy(1,1,1582) => sysmis
925 date.mdy(10,14,1582) => sysmis
926 date.mdy(10,15,1582) => 86400.00
927
928 ctime.days(date.moyr(1,2000)) => 152385.00
929 ctime.days(date.moyr(2,2000)) => 152416.00
930 ctime.days(date.moyr(3,2000)) => 152445.00
931 ctime.days(date.moyr(4,2000)) => 152476.00
932 ctime.days(date.moyr(5,2000)) => 152506.00
933 ctime.days(date.moyr(13,2000)) => 152751.00
934 ctime.days(date.moyr(14,2000)) => sysmis
935 ctime.days(date.moyr($sysmis,2000)) => sysmis
936 ctime.days(date.moyr(1,$sysmis)) => sysmis
937 ctime.days(date.moyr($sysmis,$sysmis)) => sysmis
938 date.moyr('a',2000) => error
939 date.moyr(5,'a') => error
940 date.moyr('a','b') => error
941
942 ctime.days(date.qyr(1,2000)) => 152385.00
943 ctime.days(date.qyr(2,2000)) => 152476.00
944 ctime.days(date.qyr(5,2000)) => 152751.00
945 ctime.days(date.qyr(6,2000)) => sysmis
946 ctime.days(date.qyr($sysmis,2000)) => sysmis
947 ctime.days(date.qyr(1,$sysmis)) => sysmis
948 ctime.days(date.qyr($sysmis,$sysmis)) => sysmis
949 date.qyr('a',2000) => error
950 date.qyr(5,'a') => error
951 date.qyr('a','b') => error
952
953 ctime.days(date.wkyr(1,2000)) => 152385.00
954 ctime.days(date.wkyr(15,1999)) => 152118.00
955 ctime.days(date.wkyr(36,1999)) => 152265.00
956 ctime.days(date.wkyr(54,1999)) => sysmis
957 ctime.days(date.wkyr($sysmis,1999)) => sysmis
958 ctime.days(date.wkyr(1,$sysmis)) => sysmis
959 ctime.days(date.wkyr($sysmis,$sysmis)) => sysmis
960 date.wkyr('a',1999) => error
961 date.wkyr(5,'a') => error
962 date.wkyr('a','b') => error
963
964 ctime.days(date.yrday(2000,1)) => 152385.00
965 ctime.days(date.yrday(2000,100)) => 152484.00
966 ctime.days(date.yrday(2000,253)) => 152637.00
967 ctime.days(date.yrday(2000,500)) => sysmis
968 ctime.days(date.yrday(2000,-100)) => sysmis
969 ctime.days(date.yrday(1999,$sysmis)) => sysmis
970 ctime.days(date.yrday($sysmis,1)) => sysmis
971 ctime.days(date.yrday($sysmis,$sysmis)) => sysmis
972 date.yrday(1999,'a') => error
973 date.yrday('a',5) => error
974 date.yrday('a','b') => error
975
976 xdate.date(date.mdy(6,10,1648) + time.hms(0,0,0)) / 86400 => 23981.00
977 xdate.date(date.mdy(6,30,1680) + time.hms(4,50,38)) / 86400 => 35689.00
978 xdate.date(date.mdy(7,24,1716) + time.hms(12,31,35)) / 86400 => 48861.00
979 xdate.date(date.mdy(6,19,1768) + time.hms(12,47,53)) / 86400 => 67819.00
980 xdate.date(date.mdy(8,2,1819) + time.hms(1,26,0)) / 86400 => 86489.00
981 xdate.date(date.mdy(3,27,1839) + time.hms(20,58,11)) / 86400 => 93666.00
982 xdate.date(date.mdy(4,19,1903) + time.hms(7,36,5)) / 86400 => 117064.00
983 xdate.date(date.mdy(8,25,1929) + time.hms(15,43,49)) / 86400 => 126689.00
984 xdate.date(date.mdy(9,29,1941) + time.hms(4,25,9)) / 86400 => 131107.00
985 xdate.date(date.mdy(4,19,1943) + time.hms(6,49,27)) / 86400 => 131674.00
986 xdate.date(date.mdy(10,7,1943) + time.hms(2,57,52)) / 86400 => 131845.00
987 xdate.date(date.mdy(3,17,1992) + time.hms(16,45,44)) / 86400 => 149539.00
988 xdate.date(date.mdy(2,25,1996) + time.hms(21,30,57)) / 86400 => 150979.00
989 xdate.date(date.mdy(9,29,41) + time.hms(4,25,9)) / 86400 => 131107.00
990 xdate.date(date.mdy(4,19,43) + time.hms(6,49,27)) / 86400 => 131674.00
991 xdate.date(date.mdy(10,7,43) + time.hms(2,57,52)) / 86400 => 131845.00
992 xdate.date(date.mdy(3,17,92) + time.hms(16,45,44)) / 86400 => 149539.00
993 xdate.date(date.mdy(2,25,96) + time.hms(21,30,57)) / 86400 => 150979.00
994 xdate.date(date.mdy(11,10,2038) + time.hms(22,30,4)) / 86400 => 166578.00
995 xdate.date(date.mdy(7,18,2094) + time.hms(1,56,51)) / 86400 => 186917.00
996 xdate.date(123.4) => 0.00
997 xdate.date('') => error
998
999 xdate.hour(date.mdy(6,10,1648) + time.hms(0,0,0)) => 0.00
1000 xdate.hour(date.mdy(6,30,1680) + time.hms(4,50,38)) => 4.00
1001 xdate.hour(date.mdy(7,24,1716) + time.hms(12,31,35)) => 12.00
1002 xdate.hour(date.mdy(6,19,1768) + time.hms(12,47,53)) => 12.00
1003 xdate.hour(date.mdy(8,2,1819) + time.hms(1,26,0)) => 1.00
1004 xdate.hour(date.mdy(3,27,1839) + time.hms(20,58,11)) => 20.00
1005 xdate.hour(date.mdy(4,19,1903) + time.hms(7,36,5)) => 7.00
1006 xdate.hour(date.mdy(8,25,1929) + time.hms(15,43,49)) => 15.00
1007 xdate.hour(date.mdy(9,29,1941) + time.hms(4,25,9)) => 4.00
1008 xdate.hour(date.mdy(4,19,1943) + time.hms(6,49,27)) => 6.00
1009 xdate.hour(date.mdy(10,7,1943) + time.hms(2,57,52)) => 2.00
1010 xdate.hour(date.mdy(3,17,1992) + time.hms(16,45,44)) => 16.00
1011 xdate.hour(date.mdy(2,25,1996) + time.hms(21,30,57)) => 21.00
1012 xdate.hour(date.mdy(9,29,41) + time.hms(4,25,9)) => 4.00
1013 xdate.hour(date.mdy(4,19,43) + time.hms(6,49,27)) => 6.00
1014 xdate.hour(date.mdy(10,7,43) + time.hms(2,57,52)) => 2.00
1015 xdate.hour(date.mdy(3,17,92) + time.hms(16,45,44)) => 16.00
1016 xdate.hour(date.mdy(2,25,96) + time.hms(21,30,57)) => 21.00
1017 xdate.hour(date.mdy(11,10,2038) + time.hms(22,30,4)) => 22.00
1018 xdate.hour(date.mdy(7,18,2094) + time.hms(1,56,51)) => 1.00
1019 xdate.hour(-1) => -1.00
1020 xdate.hour(1) => 0.00
1021 xdate.hour($sysmis) => sysmis
1022 xdate.hour('') => error
1023
1024 xdate.jday(date.mdy(6,10,1648) + time.hms(0,0,0)) => 162.00
1025 xdate.jday(date.mdy(6,30,1680) + time.hms(4,50,38)) => 182.00
1026 xdate.jday(date.mdy(7,24,1716) + time.hms(12,31,35)) => 206.00
1027 xdate.jday(date.mdy(6,19,1768) + time.hms(12,47,53)) => 171.00
1028 xdate.jday(date.mdy(8,2,1819) + time.hms(1,26,0)) => 214.00
1029 xdate.jday(date.mdy(3,27,1839) + time.hms(20,58,11)) => 86.00
1030 xdate.jday(date.mdy(4,19,1903) + time.hms(7,36,5)) => 109.00
1031 xdate.jday(date.mdy(8,25,1929) + time.hms(15,43,49)) => 237.00
1032 xdate.jday(date.mdy(9,29,1941) + time.hms(4,25,9)) => 272.00
1033 xdate.jday(date.mdy(4,19,1943) + time.hms(6,49,27)) => 109.00
1034 xdate.jday(date.mdy(10,7,1943) + time.hms(2,57,52)) => 280.00
1035 xdate.jday(date.mdy(3,17,1992) + time.hms(16,45,44)) => 77.00
1036 xdate.jday(date.mdy(2,25,1996) + time.hms(21,30,57)) => 56.00
1037 xdate.jday(date.mdy(9,29,41) + time.hms(4,25,9)) => 272.00
1038 xdate.jday(date.mdy(4,19,43) + time.hms(6,49,27)) => 109.00
1039 xdate.jday(date.mdy(10,7,43) + time.hms(2,57,52)) => 280.00
1040 xdate.jday(date.mdy(3,17,92) + time.hms(16,45,44)) => 77.00
1041 xdate.jday(date.mdy(2,25,96) + time.hms(21,30,57)) => 56.00
1042 xdate.jday(date.mdy(11,10,2038) + time.hms(22,30,4)) => 314.00
1043 xdate.jday(date.mdy(7,18,2094) + time.hms(1,56,51)) => 199.00
1044 xdate.jday(0) => sysmis
1045 xdate.jday(1) => sysmis
1046 xdate.jday(86400) => 288.00
1047
1048 xdate.mday(date.mdy(6,10,1648) + time.hms(0,0,0)) => 10.00
1049 xdate.mday(date.mdy(6,30,1680) + time.hms(4,50,38)) => 30.00
1050 xdate.mday(date.mdy(7,24,1716) + time.hms(12,31,35)) => 24.00
1051 xdate.mday(date.mdy(6,19,1768) + time.hms(12,47,53)) => 19.00
1052 xdate.mday(date.mdy(8,2,1819) + time.hms(1,26,0)) => 2.00
1053 xdate.mday(date.mdy(3,27,1839) + time.hms(20,58,11)) => 27.00
1054 xdate.mday(date.mdy(4,19,1903) + time.hms(7,36,5)) => 19.00
1055 xdate.mday(date.mdy(8,25,1929) + time.hms(15,43,49)) => 25.00
1056 xdate.mday(date.mdy(9,29,1941) + time.hms(4,25,9)) => 29.00
1057 xdate.mday(date.mdy(4,19,1943) + time.hms(6,49,27)) => 19.00
1058 xdate.mday(date.mdy(10,7,1943) + time.hms(2,57,52)) => 7.00
1059 xdate.mday(date.mdy(3,17,1992) + time.hms(16,45,44)) => 17.00
1060 xdate.mday(date.mdy(2,25,1996) + time.hms(21,30,57)) => 25.00
1061 xdate.mday(date.mdy(9,29,41) + time.hms(4,25,9)) => 29.00
1062 xdate.mday(date.mdy(4,19,43) + time.hms(6,49,27)) => 19.00
1063 xdate.mday(date.mdy(10,7,43) + time.hms(2,57,52)) => 7.00
1064 xdate.mday(date.mdy(3,17,92) + time.hms(16,45,44)) => 17.00
1065 xdate.mday(date.mdy(2,25,96) + time.hms(21,30,57)) => 25.00
1066 xdate.mday(date.mdy(11,10,2038) + time.hms(22,30,4)) => 10.00
1067 xdate.mday(date.mdy(7,18,2094) + time.hms(1,56,51)) => 18.00
1068
1069 xdate.minute(date.mdy(6,10,1648) + time.hms(0,0,0)) => 0.00
1070 xdate.minute(date.mdy(6,30,1680) + time.hms(4,50,38)) => 50.00
1071 xdate.minute(date.mdy(7,24,1716) + time.hms(12,31,35)) => 31.00
1072 xdate.minute(date.mdy(6,19,1768) + time.hms(12,47,53)) => 47.00
1073 xdate.minute(date.mdy(8,2,1819) + time.hms(1,26,0)) => 26.00
1074 xdate.minute(date.mdy(3,27,1839) + time.hms(20,58,11)) => 58.00
1075 xdate.minute(date.mdy(4,19,1903) + time.hms(7,36,5)) => 36.00
1076 xdate.minute(date.mdy(8,25,1929) + time.hms(15,43,49)) => 43.00
1077 xdate.minute(date.mdy(9,29,1941) + time.hms(4,25,9)) => 25.00
1078 xdate.minute(date.mdy(4,19,1943) + time.hms(6,49,27)) => 49.00
1079 xdate.minute(date.mdy(10,7,1943) + time.hms(2,57,52)) => 57.00
1080 xdate.minute(date.mdy(3,17,1992) + time.hms(16,45,44)) => 45.00
1081 xdate.minute(date.mdy(2,25,1996) + time.hms(21,30,57)) => 30.00
1082 xdate.minute(date.mdy(9,29,41) + time.hms(4,25,9)) => 25.00
1083 xdate.minute(date.mdy(4,19,43) + time.hms(6,49,27)) => 49.00
1084 xdate.minute(date.mdy(10,7,43) + time.hms(2,57,52)) => 57.00
1085 xdate.minute(date.mdy(3,17,92) + time.hms(16,45,44)) => 45.00
1086 xdate.minute(date.mdy(2,25,96) + time.hms(21,30,57)) => 30.00
1087 xdate.minute(date.mdy(11,10,2038) + time.hms(22,30,4)) => 30.00
1088 xdate.minute(date.mdy(7,18,2094) + time.hms(1,56,51)) => 56.00
1089
1090 xdate.month(date.mdy(6,10,1648) + time.hms(0,0,0)) => 6.00
1091 xdate.month(date.mdy(6,30,1680) + time.hms(4,50,38)) => 6.00
1092 xdate.month(date.mdy(7,24,1716) + time.hms(12,31,35)) => 7.00
1093 xdate.month(date.mdy(6,19,1768) + time.hms(12,47,53)) => 6.00
1094 xdate.month(date.mdy(8,2,1819) + time.hms(1,26,0)) => 8.00
1095 xdate.month(date.mdy(3,27,1839) + time.hms(20,58,11)) => 3.00
1096 xdate.month(date.mdy(4,19,1903) + time.hms(7,36,5)) => 4.00
1097 xdate.month(date.mdy(8,25,1929) + time.hms(15,43,49)) => 8.00
1098 xdate.month(date.mdy(9,29,1941) + time.hms(4,25,9)) => 9.00
1099 xdate.month(date.mdy(4,19,1943) + time.hms(6,49,27)) => 4.00
1100 xdate.month(date.mdy(10,7,1943) + time.hms(2,57,52)) => 10.00
1101 xdate.month(date.mdy(3,17,1992) + time.hms(16,45,44)) => 3.00
1102 xdate.month(date.mdy(2,25,1996) + time.hms(21,30,57)) => 2.00
1103 xdate.month(date.mdy(9,29,41) + time.hms(4,25,9)) => 9.00
1104 xdate.month(date.mdy(4,19,43) + time.hms(6,49,27)) => 4.00
1105 xdate.month(date.mdy(10,7,43) + time.hms(2,57,52)) => 10.00
1106 xdate.month(date.mdy(3,17,92) + time.hms(16,45,44)) => 3.00
1107 xdate.month(date.mdy(2,25,96) + time.hms(21,30,57)) => 2.00
1108 xdate.month(date.mdy(11,10,2038) + time.hms(22,30,4)) => 11.00
1109 xdate.month(date.mdy(7,18,2094) + time.hms(1,56,51)) => 7.00
1110
1111 xdate.quarter(date.mdy(6,10,1648) + time.hms(0,0,0)) => 2.00
1112 xdate.quarter(date.mdy(6,30,1680) + time.hms(4,50,38)) => 2.00
1113 xdate.quarter(date.mdy(7,24,1716) + time.hms(12,31,35)) => 3.00
1114 xdate.quarter(date.mdy(6,19,1768) + time.hms(12,47,53)) => 2.00
1115 xdate.quarter(date.mdy(8,2,1819) + time.hms(1,26,0)) => 3.00
1116 xdate.quarter(date.mdy(3,27,1839) + time.hms(20,58,11)) => 1.00
1117 xdate.quarter(date.mdy(4,19,1903) + time.hms(7,36,5)) => 2.00
1118 xdate.quarter(date.mdy(8,25,1929) + time.hms(15,43,49)) => 3.00
1119 xdate.quarter(date.mdy(9,29,1941) + time.hms(4,25,9)) => 3.00
1120 xdate.quarter(date.mdy(4,19,1943) + time.hms(6,49,27)) => 2.00
1121 xdate.quarter(date.mdy(10,7,1943) + time.hms(2,57,52)) => 4.00
1122 xdate.quarter(date.mdy(3,17,1992) + time.hms(16,45,44)) => 1.00
1123 xdate.quarter(date.mdy(2,25,1996) + time.hms(21,30,57)) => 1.00
1124 xdate.quarter(date.mdy(9,29,41) + time.hms(4,25,9)) => 3.00
1125 xdate.quarter(date.mdy(4,19,43) + time.hms(6,49,27)) => 2.00
1126 xdate.quarter(date.mdy(10,7,43) + time.hms(2,57,52)) => 4.00
1127 xdate.quarter(date.mdy(3,17,92) + time.hms(16,45,44)) => 1.00
1128 xdate.quarter(date.mdy(2,25,96) + time.hms(21,30,57)) => 1.00
1129 xdate.quarter(date.mdy(11,10,2038) + time.hms(22,30,4)) => 4.00
1130 xdate.quarter(date.mdy(7,18,2094) + time.hms(1,56,51)) => 3.00
1131
1132 xdate.second(date.mdy(6,10,1648) + time.hms(0,0,0)) => 0.00
1133 xdate.second(date.mdy(6,30,1680) + time.hms(4,50,38)) => 38.00
1134 xdate.second(date.mdy(7,24,1716) + time.hms(12,31,35)) => 35.00
1135 xdate.second(date.mdy(6,19,1768) + time.hms(12,47,53)) => 53.00
1136 xdate.second(date.mdy(8,2,1819) + time.hms(1,26,0)) => 0.00
1137 xdate.second(date.mdy(3,27,1839) + time.hms(20,58,11)) => 11.00
1138 xdate.second(date.mdy(4,19,1903) + time.hms(7,36,5)) => 5.00
1139 xdate.second(date.mdy(8,25,1929) + time.hms(15,43,49)) => 49.00
1140 xdate.second(date.mdy(9,29,1941) + time.hms(4,25,9)) => 9.00
1141 xdate.second(date.mdy(4,19,1943) + time.hms(6,49,27)) => 27.00
1142 xdate.second(date.mdy(10,7,1943) + time.hms(2,57,52)) => 52.00
1143 xdate.second(date.mdy(3,17,1992) + time.hms(16,45,44)) => 44.00
1144 xdate.second(date.mdy(2,25,1996) + time.hms(21,30,57)) => 57.00
1145 xdate.second(date.mdy(9,29,41) + time.hms(4,25,9)) => 9.00
1146 xdate.second(date.mdy(4,19,43) + time.hms(6,49,27)) => 27.00
1147 xdate.second(date.mdy(10,7,43) + time.hms(2,57,52)) => 52.00
1148 xdate.second(date.mdy(3,17,92) + time.hms(16,45,44)) => 44.00
1149 xdate.second(date.mdy(2,25,96) + time.hms(21,30,57)) => 57.00
1150 xdate.second(date.mdy(11,10,2038) + time.hms(22,30,4)) => 4.00
1151 xdate.second(date.mdy(7,18,2094) + time.hms(1,56,51)) => 51.00
1152
1153 xdate.tday(date.mdy(6,10,1648) + time.hms(0,0,0)) => 23981.00
1154 xdate.tday(date.mdy(6,30,1680) + time.hms(4,50,38)) => 35689.00
1155 xdate.tday(date.mdy(7,24,1716) + time.hms(12,31,35)) => 48861.00
1156 xdate.tday(date.mdy(6,19,1768) + time.hms(12,47,53)) => 67819.00
1157 xdate.tday(date.mdy(8,2,1819) + time.hms(1,26,0)) => 86489.00
1158 xdate.tday(date.mdy(3,27,1839) + time.hms(20,58,11)) => 93666.00
1159 xdate.tday(date.mdy(4,19,1903) + time.hms(7,36,5)) => 117064.00
1160 xdate.tday(date.mdy(8,25,1929) + time.hms(15,43,49)) => 126689.00
1161 xdate.tday(date.mdy(9,29,1941) + time.hms(4,25,9)) => 131107.00
1162 xdate.tday(date.mdy(4,19,1943) + time.hms(6,49,27)) => 131674.00
1163 xdate.tday(date.mdy(10,7,1943) + time.hms(2,57,52)) => 131845.00
1164 xdate.tday(date.mdy(3,17,1992) + time.hms(16,45,44)) => 149539.00
1165 xdate.tday(date.mdy(2,25,1996) + time.hms(21,30,57)) => 150979.00
1166 xdate.tday(date.mdy(9,29,41) + time.hms(4,25,9)) => 131107.00
1167 xdate.tday(date.mdy(4,19,43) + time.hms(6,49,27)) => 131674.00
1168 xdate.tday(date.mdy(10,7,43) + time.hms(2,57,52)) => 131845.00
1169 xdate.tday(date.mdy(3,17,92) + time.hms(16,45,44)) => 149539.00
1170 xdate.tday(date.mdy(2,25,96) + time.hms(21,30,57)) => 150979.00
1171 xdate.tday(date.mdy(11,10,2038) + time.hms(22,30,4)) => 166578.00
1172 xdate.tday(date.mdy(7,18,2094) + time.hms(1,56,51)) => 186917.00
1173
1174 xdate.time(date.mdy(6,10,1648) + time.hms(0,0,0)) => 0.00
1175 xdate.time(date.mdy(6,30,1680) + time.hms(4,50,38)) => 17438.00
1176 xdate.time(date.mdy(7,24,1716) + time.hms(12,31,35)) => 45095.00
1177 xdate.time(date.mdy(6,19,1768) + time.hms(12,47,53)) => 46073.00
1178 xdate.time(date.mdy(8,2,1819) + time.hms(1,26,0)) => 5160.00
1179 xdate.time(date.mdy(3,27,1839) + time.hms(20,58,11)) => 75491.00
1180 xdate.time(date.mdy(4,19,1903) + time.hms(7,36,5)) => 27365.00
1181 xdate.time(date.mdy(8,25,1929) + time.hms(15,43,49)) => 56629.00
1182 xdate.time(date.mdy(9,29,1941) + time.hms(4,25,9)) => 15909.00
1183 xdate.time(date.mdy(4,19,1943) + time.hms(6,49,27)) => 24567.00
1184 xdate.time(date.mdy(10,7,1943) + time.hms(2,57,52)) => 10672.00
1185 xdate.time(date.mdy(3,17,1992) + time.hms(16,45,44)) => 60344.00
1186 xdate.time(date.mdy(2,25,1996) + time.hms(21,30,57)) => 77457.00
1187 xdate.time(date.mdy(9,29,41) + time.hms(4,25,9)) => 15909.00
1188 xdate.time(date.mdy(4,19,43) + time.hms(6,49,27)) => 24567.00
1189 xdate.time(date.mdy(10,7,43) + time.hms(2,57,52)) => 10672.00
1190 xdate.time(date.mdy(3,17,92) + time.hms(16,45,44)) => 60344.00
1191 xdate.time(date.mdy(2,25,96) + time.hms(21,30,57)) => 77457.00
1192 xdate.time(date.mdy(11,10,2038) + time.hms(22,30,4)) => 81004.00
1193 xdate.time(date.mdy(7,18,2094) + time.hms(1,56,51)) => 7011.00
1194
1195 xdate.week(date.mdy(6,10,1648) + time.hms(0,0,0)) => 24.00
1196 xdate.week(date.mdy(6,30,1680) + time.hms(4,50,38)) => 26.00
1197 xdate.week(date.mdy(7,24,1716) + time.hms(12,31,35)) => 30.00
1198 xdate.week(date.mdy(6,19,1768) + time.hms(12,47,53)) => 25.00
1199 xdate.week(date.mdy(8,2,1819) + time.hms(1,26,0)) => 31.00
1200 xdate.week(date.mdy(3,27,1839) + time.hms(20,58,11)) => 13.00
1201 xdate.week(date.mdy(4,19,1903) + time.hms(7,36,5)) => 16.00
1202 xdate.week(date.mdy(8,25,1929) + time.hms(15,43,49)) => 34.00
1203 xdate.week(date.mdy(9,29,1941) + time.hms(4,25,9)) => 39.00
1204 xdate.week(date.mdy(4,19,1943) + time.hms(6,49,27)) => 16.00
1205 xdate.week(date.mdy(10,7,1943) + time.hms(2,57,52)) => 40.00
1206 xdate.week(date.mdy(3,17,1992) + time.hms(16,45,44)) => 11.00
1207 xdate.week(date.mdy(2,25,1996) + time.hms(21,30,57)) => 8.00
1208 xdate.week(date.mdy(9,29,41) + time.hms(4,25,9)) => 39.00
1209 xdate.week(date.mdy(4,19,43) + time.hms(6,49,27)) => 16.00
1210 xdate.week(date.mdy(10,7,43) + time.hms(2,57,52)) => 40.00
1211 xdate.week(date.mdy(3,17,92) + time.hms(16,45,44)) => 11.00
1212 xdate.week(date.mdy(2,25,96) + time.hms(21,30,57)) => 8.00
1213 xdate.week(date.mdy(11,10,2038) + time.hms(22,30,4)) => 45.00
1214 xdate.week(date.mdy(7,18,2094) + time.hms(1,56,51)) => 29.00
1215
1216 xdate.wkday(date.mdy(6,10,1648)) => 4.00
1217 xdate.wkday(date.mdy(6,30,1680)) => 1.00
1218 xdate.wkday(date.mdy(7,24,1716)) => 6.00
1219 xdate.wkday(date.mdy(6,19,1768)) => 1.00
1220 xdate.wkday(date.mdy(8,2,1819)) => 2.00
1221 xdate.wkday(date.mdy(3,27,1839)) => 4.00
1222 xdate.wkday(date.mdy(4,19,1903)) => 1.00
1223 xdate.wkday(date.mdy(8,25,1929)) => 1.00
1224 xdate.wkday(date.mdy(9,29,1941)) => 2.00
1225 xdate.wkday(date.mdy(4,19,1943)) => 2.00
1226 xdate.wkday(date.mdy(10,7,1943)) => 5.00
1227 xdate.wkday(date.mdy(3,17,1992)) => 3.00
1228 xdate.wkday(date.mdy(2,25,1996)) => 1.00
1229 xdate.wkday(date.mdy(9,29,41)) => 2.00
1230 xdate.wkday(date.mdy(4,19,43)) => 2.00
1231 xdate.wkday(date.mdy(10,7,43)) => 5.00
1232 xdate.wkday(date.mdy(3,17,92)) => 3.00
1233 xdate.wkday(date.mdy(2,25,96)) => 1.00
1234 xdate.wkday(date.mdy(11,10,2038)) => 4.00
1235 xdate.wkday(date.mdy(7,18,2094)) => 1.00
1236
1237 xdate.year(date.mdy(6,10,1648) + time.hms(0,0,0)) => 1648.00
1238 xdate.year(date.mdy(6,30,1680) + time.hms(4,50,38)) => 1680.00
1239 xdate.year(date.mdy(7,24,1716) + time.hms(12,31,35)) => 1716.00
1240 xdate.year(date.mdy(6,19,1768) + time.hms(12,47,53)) => 1768.00
1241 xdate.year(date.mdy(8,2,1819) + time.hms(1,26,0)) => 1819.00
1242 xdate.year(date.mdy(3,27,1839) + time.hms(20,58,11)) => 1839.00
1243 xdate.year(date.mdy(4,19,1903) + time.hms(7,36,5)) => 1903.00
1244 xdate.year(date.mdy(8,25,1929) + time.hms(15,43,49)) => 1929.00
1245 xdate.year(date.mdy(9,29,1941) + time.hms(4,25,9)) => 1941.00
1246 xdate.year(date.mdy(4,19,1943) + time.hms(6,49,27)) => 1943.00
1247 xdate.year(date.mdy(10,7,1943) + time.hms(2,57,52)) => 1943.00
1248 xdate.year(date.mdy(3,17,1992) + time.hms(16,45,44)) => 1992.00
1249 xdate.year(date.mdy(2,25,1996) + time.hms(21,30,57)) => 1996.00
1250 xdate.year(date.mdy(9,29,41) + time.hms(4,25,9)) => 1941.00
1251 xdate.year(date.mdy(4,19,43) + time.hms(6,49,27)) => 1943.00
1252 xdate.year(date.mdy(10,7,43) + time.hms(2,57,52)) => 1943.00
1253 xdate.year(date.mdy(3,17,92) + time.hms(16,45,44)) => 1992.00
1254 xdate.year(date.mdy(2,25,96) + time.hms(21,30,57)) => 1996.00
1255 xdate.year(date.mdy(11,10,2038) + time.hms(22,30,4)) => 2038.00
1256 xdate.year(date.mdy(7,18,2094) + time.hms(1,56,51)) => 2094.00
1257
1258 # These test values are from Applied Statistics, Algorithm AS 310.
1259 1000 * ncdf.beta(.868,10,20,150) => 937.66
1260 1000 * ncdf.beta(.9,10,10,120) => 730.68
1261 1000 * ncdf.beta(.88,15,5,80) => 160.43
1262 1000 * ncdf.beta(.85,20,10,110) => 186.75
1263 1000 * ncdf.beta(.66,20,30,65) => 655.94
1264 1000 * ncdf.beta(.72,20,50,130) => 979.69
1265 1000 * ncdf.beta(.72,30,20,80) => 116.24
1266 1000 * ncdf.beta(.8,30,40,130) => 993.04
1267
1268 # FIXME: LAG
1269
1270 (X = 1.00); X => 1.00
1271 SYSMIS(1) => false
1272 SYSMIS($SYSMIS) => true
1273 SYSMIS(1 + $SYSMIS) => true
1274
1275 # FIXME: out-of-range and nearly out-of-range values on dates
1276 EOF
1277 if [ $? -ne 0 ] ; then no_result ; fi
1278
1279 activity="create optimizing input"
1280 echo 'set mxwarn 1000.
1281 set mxerr 1000.' > $TEMPDIR/expr-opt.stat
1282 sed < $TEMPDIR/expr-list >> $TEMPDIR/expr-opt.stat \
1283         -e 's#^\(\(.*\); \)*\(.*\) => .*$#DEBUG EVALUATE\2/\3.#'
1284 if [ $? -ne 0 ] ; then no_result ; fi
1285 cp $TEMPDIR/expr-opt.stat ~/foo
1286
1287 activity="run optimizing program"
1288 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii \
1289          $TEMPDIR/expr-opt.stat >$TEMPDIR/expr-opt.err 2> $TEMPDIR/expr-opt.out
1290
1291 activity="compare optimizing output"
1292 diff -B -b $TEMPDIR/expr-list $TEMPDIR/expr-opt.out
1293 if [ $? -ne 0 ] ; then fail ; fi
1294
1295 activity="create non-optimizing input"
1296 echo 'set mxwarn 1000.
1297 set mxerr 1000.' > $TEMPDIR/expr-noopt.stat
1298 sed < $TEMPDIR/expr-list >> $TEMPDIR/expr-noopt.stat \
1299         -e 's#^\(\(.*\); \)*\(.*\) => .*$#DEBUG EVALUATE NOOPTIMIZE\2/\3.#'
1300 if [ $? -ne 0 ] ; then no_result ; fi
1301
1302 activity="run non-optimizing program"
1303 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii \
1304         $TEMPDIR/expr-noopt.stat >$TEMPDIR/expr-noopt.err 2> $TEMPDIR/expr-noopt.out
1305
1306 activity="compare non-optimizing output"
1307 diff -B -b $TEMPDIR/expr-list $TEMPDIR/expr-noopt.out
1308 if [ $? -ne 0 ] ; then fail ; fi
1309
1310 activity="create optimizing postfix input"
1311 echo 'set mxwarn 1000.
1312 set mxerr 1000.' > $TEMPDIR/expr-opt-pos.stat
1313 sed < $TEMPDIR/expr-list >> $TEMPDIR/expr-opt-pos.stat \
1314         -e 's#^\(\(.*\); \)*\(.*\) => .*$#DEBUG EVALUATE POSTFIX\2/\3.#'
1315 if [ $? -ne 0 ] ; then no_result ; fi
1316
1317 activity="run optimizing postfix program"
1318 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii \
1319          $TEMPDIR/expr-opt-pos.stat >$TEMPDIR/expr-opt-pos.err 2> $TEMPDIR/expr-opt-pos.out
1320 if [ $? -eq 0 ] ; then no_result ; fi
1321
1322 activity="create non-optimizing postfix input"
1323 echo 'set mxwarn 1000.
1324 set mxerr 1000.' > $TEMPDIR/expr-noopt-pos.stat
1325 sed < $TEMPDIR/expr-list >> $TEMPDIR/expr-noopt-pos.stat \
1326         -e 's#^\(\(.*\); \)*\(.*\) => .*$#DEBUG EVALUATE NOOPTIMIZE POSTFIX\2/\3.#'
1327 if [ $? -ne 0 ] ; then no_result ; fi
1328
1329 activity="run non-optimizing postfix program"
1330 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii \
1331         $TEMPDIR/expr-noopt-pos.stat >$TEMPDIR/expr-noopt-pos.err 2> $TEMPDIR/expr-noopt-pos.out
1332 if [ $? -eq 0 ] ; then no_result ; fi
1333
1334 pass