/[pspp]/pspp/tests/xforms/expressions.sh
ViewVC logotype

Diff of /pspp/tests/xforms/expressions.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by blp, Tue Jul 26 03:51:30 2005 UTC revision 1.4 by blp, Tue Aug 2 04:50:18 2005 UTC
# Line 15  export STAT_CONFIG_PATH Line 15  export STAT_CONFIG_PATH
15    
16  cleanup()  cleanup()
17  {  {
18         cd /
19       rm -rf $TEMPDIR       rm -rf $TEMPDIR
      :  
20  }  }
21    
22    
# Line 47  mkdir -p $TEMPDIR Line 47  mkdir -p $TEMPDIR
47    
48  cd $TEMPDIR  cd $TEMPDIR
49  activity="create expressions list"  activity="create expressions list"
50  sed -ne 's/#.*//;/^[    ]*$/!p' > $TEMPDIR/expr-list <<'EOF'  cat > 00-num-syn.expr <<'EOF'
51    # Test numeric syntax.
 # Number syntax.  
52  1e2 => 100.00  1e2 => 100.00
53  1e+2 => 100.00  1e+2 => 100.00
54  1e-2 => 0.01  1e-2 => 0.01
55  1e-99 => 0.00  1e-99 => 0.00
56    EOF
57    
58    cat > 01-conv-to-num.expr <<'EOF'
59  # Test using numeric/string values as Booleans and vice-versa  # Test using numeric/string values as Booleans and vice-versa
60  0 AND 1 => false  0 AND 1 => false
61  $true AND 1 => true  $true AND 1 => true
# Line 66  $true AND 1 => true Line 67  $true AND 1 => true
67  0 AND $sysmis => false  0 AND $sysmis => false
68  (1>2) + 1 => 1.00  (1>2) + 1 => 1.00
69  $true + $false => 1.00  $true + $false => 1.00
70    EOF
71    
72    cat > 02-add-sub.expr <<'EOF'
73  # Addition and subtraction.  # Addition and subtraction.
74  1 + 2 => 3.00  1 + 2 => 3.00
75  1 + $true => 2.00  1 + $true => 2.00
# Line 82  $true - 4/3 => -0.33 Line 85  $true - 4/3 => -0.33
85  9.5 - '' => error  9.5 - '' => error
86  1 - 2 => -1.00  1 - 2 => -1.00
87  52 -23 => 29.00  52 -23 => 29.00
88    EOF
89    
90    cat > 03-mul-div.expr <<'EOF'
91  # Multiplication and division  # Multiplication and division
92  5 * 10 => 50.00  5 * 10 => 50.00
93  10 * $true => 10.00  10 * $true => 10.00
# Line 94  $sysmis * 15 => sysmis Line 99  $sysmis * 15 => sysmis
99  1 / 2 => 0.50  1 / 2 => 0.50
100  2 / 5 => 0.40  2 / 5 => 0.40
101  12 / 3 / 2 => 2.00  12 / 3 / 2 => 2.00
102    EOF
103    
104    cat > 04-exp.expr <<'EOF'
105  # Exponentiation.  # Exponentiation.
106  2**8 => 256.00  2**8 => 256.00
107  (2**3)**4 => 4096.00    # Irritating, but compatible.  (2**3)**4 => 4096.00    # Irritating, but compatible.
108  2**3**4 => 4096.00  2**3**4 => 4096.00
109    EOF
110    
111    cat > 05-negation.expr <<'EOF'
112  # Unary minus.  # Unary minus.
113  2+-3 => -1.00  2+-3 => -1.00
114  2*-3 => -6.00  2*-3 => -6.00
# Line 109  $sysmis * 15 => sysmis Line 118  $sysmis * 15 => sysmis
118  0**0 => sysmis  0**0 => sysmis
119  0**-1 => sysmis  0**-1 => sysmis
120  (-3)**1.5 => sysmis  (-3)**1.5 => sysmis
121    EOF
122    
123    cat > 06-logical-and.expr <<'EOF'
124  # AND truth table.  # AND truth table.
125  $false AND $false => false  $false AND $false => false
126  $false AND $true => false  $false AND $true => false
# Line 129  $true & $sysmis => sysmis Line 140  $true & $sysmis => sysmis
140  $sysmis & $false => false  $sysmis & $false => false
141  $sysmis & $true => sysmis  $sysmis & $true => sysmis
142  $sysmis & $sysmis => sysmis  $sysmis & $sysmis => sysmis
143    EOF
144    
145    cat > 07-logical-or.expr <<'EOF'
146  # OR truth table.  # OR truth table.
147  $false OR $false => false  $false OR $false => false
148  $false OR $true => true  $false OR $true => true
# Line 149  $true | $sysmis => true Line 162  $true | $sysmis => true
162  $sysmis | $false => sysmis  $sysmis | $false => sysmis
163  $sysmis | $true => true  $sysmis | $true => true
164  $sysmis | $sysmis => sysmis  $sysmis | $sysmis => sysmis
165    EOF
166    
167    cat > 08-logical-not.expr <<'EOF'
168  # NOT truth table.  # NOT truth table.
169  not $false => true  not $false => true
170  not 0 => true  not 0 => true
# Line 163  not $sysmis => sysmis Line 178  not $sysmis => sysmis
178  ~ $true => false  ~ $true => false
179  ~ 1 => false  ~ 1 => false
180  ~ $sysmis => sysmis  ~ $sysmis => sysmis
181    EOF
182    
183    cat > 09-eq.expr <<'EOF'
184  # Relational operators.  # Relational operators.
185  1 eq 1 => true  1 eq 1 => true
186  1 = 1 => true  1 = 1 => true
# Line 182  not $sysmis => sysmis Line 199  not $sysmis => sysmis
199  1 >= 2 = 2 ge 3 => false        # Check precedence.  1 >= 2 = 2 ge 3 => false        # Check precedence.
200  3 ne 2 ~= 1 => false            # Mathematically true.  3 ne 2 ~= 1 => false            # Mathematically true.
201  3 > 2 > 1 => false              # Mathematically true.  3 > 2 > 1 => false              # Mathematically true.
202    EOF
203    
204    cat > 10-le.expr <<'EOF'
205  1 <= 2 => true  1 <= 2 => true
206  2.5 <= 1.5 => false  2.5 <= 1.5 => false
207  1 le 2 => true  1 le 2 => true
# Line 198  not $sysmis => sysmis Line 217  not $sysmis => sysmis
217  '0124' le '0123' => false  '0124' le '0123' => false
218  '0123  ' <= '0123' => true  '0123  ' <= '0123' => true
219  '0123' le '0123  ' => true  '0123' le '0123  ' => true
220    EOF
221    
222    cat > 11-lt.expr <<'EOF'
223  1 < 2 => true  1 < 2 => true
224  2.5 < 1.5 => false  2.5 < 1.5 => false
225  3.5 lt 4 => true  3.5 lt 4 => true
# Line 212  not $sysmis => sysmis Line 233  not $sysmis => sysmis
233  '0124' lt '0123' => false  '0124' lt '0123' => false
234  '0123  ' < '0123' => false  '0123  ' < '0123' => false
235  '0123' lt '0123  ' => false  '0123' lt '0123  ' => false
236    EOF
237    
238    cat > 12-ge.expr <<'EOF'
239  1 >= 2 => false  1 >= 2 => false
240  2.5 >= 1.5 => true  2.5 >= 1.5 => true
241  1 ge 2 => false  1 ge 2 => false
# Line 228  not $sysmis => sysmis Line 251  not $sysmis => sysmis
251  '0124' >= '0123' => true  '0124' >= '0123' => true
252  '0123  ' ge '0123' => true  '0123  ' ge '0123' => true
253  '0123' >= '0123  ' => true  '0123' >= '0123  ' => true
254    EOF
255    
256    cat > 13-gt.expr <<'EOF'
257  1 > 2 => false  1 > 2 => false
258  2.5 > 1.5 => true  2.5 > 1.5 => true
259  3.5 gt 4 => false  3.5 gt 4 => false
# Line 242  not $sysmis => sysmis Line 267  not $sysmis => sysmis
267  '0124' gt '0123' => true  '0124' gt '0123' => true
268  '0123  ' > '0123' => false  '0123  ' > '0123' => false
269  '0123' gt '0123  ' => false  '0123' gt '0123  ' => false
270    EOF
271    
272    cat > 14-ne.expr <<'EOF'
273  1 ne 1 => false  1 ne 1 => false
274  1 ~= 1 => false  1 ~= 1 => false
275  1 <> 2 => true  1 <> 2 => true
# Line 258  not $sysmis => sysmis Line 285  not $sysmis => sysmis
285  'asdfj   ' ne 'asdf' => true  'asdfj   ' ne 'asdf' => true
286  1 < > 1 => error        # <> token can't be split  1 < > 1 => error        # <> token can't be split
287  1 ~ = 1 => error        # ~= token can't be split  1 ~ = 1 => error        # ~= token can't be split
288    EOF
289    
290    cat > 15-exp-log.expr <<'EOF'
291  exp(10) => 22026.47  exp(10) => 22026.47
292  exp('x') => error  exp('x') => error
293    
# Line 267  lg10('x') => error Line 296  lg10('x') => error
296    
297  ln(10) => 2.30  ln(10) => 2.30
298  ln('x') => error  ln('x') => error
299    EOF
300    
301    cat > 16-sqrt-abs-mod.expr <<'EOF'
302  sqrt(500) => 22.36  sqrt(500) => 22.36
303  sqrt('x') => error  sqrt('x') => error
304    
# Line 287  mod('a', 'b') => error Line 318  mod('a', 'b') => error
318  mod10(55.5) => 5.50  mod10(55.5) => 5.50
319  mod10(-55.5) => -5.50  mod10(-55.5) => -5.50
320  mod10('x') => error  mod10('x') => error
321    EOF
322    
323    cat > 17-rnd-trunc.expr <<'EOF'
324  rnd(5.4) => 5.00  rnd(5.4) => 5.00
325  rnd(5.6) => 6.00  rnd(5.6) => 6.00
326  rnd(-5.4) => -5.00  rnd(-5.4) => -5.00
# Line 299  trunc(1.9) => 1.00 Line 332  trunc(1.9) => 1.00
332  trunc(-1.2) => -1.00  trunc(-1.2) => -1.00
333  trunc(-1.9) => -1.00  trunc(-1.9) => -1.00
334  trunc('x') => error  trunc('x') => error
335    EOF
336    
337    cat > 18-arc.expr <<'EOF'
338  acos(.5) / 3.14159 * 180 => 60.00  acos(.5) / 3.14159 * 180 => 60.00
339  arcos(.75) / 3.14159 * 180 => 41.41  arcos(.75) / 3.14159 * 180 => 41.41
340  arcos(-.5) / 3.14159 * 180 => 120.00  arcos(-.5) / 3.14159 * 180 => 120.00
# Line 323  atan(10) / 3.14159 * 180 => 84.29 Line 358  atan(10) / 3.14159 * 180 => 84.29
358  artan(-1) / 3.14159 * 180 => -45.00  artan(-1) / 3.14159 * 180 => -45.00
359  atan(-10) / 3.14159 * 180 => -84.29  atan(-10) / 3.14159 * 180 => -84.29
360  artan('x') => error  artan('x') => error
361    EOF
362    
363    cat > 19-cos-sin-tan.expr <<'EOF'
364  cos(60 / 180 * 3.14159) => 0.50  cos(60 / 180 * 3.14159) => 0.50
365  cos(45 / 180 * 3.14159) => 0.71  cos(45 / 180 * 3.14159) => 0.71
366  cos(30 / 180 * 3.14159) => 0.87  cos(30 / 180 * 3.14159) => 0.87
# Line 359  tan(-15 / 180 * 3.14159) => -0.27 Line 396  tan(-15 / 180 * 3.14159) => -0.27
396  tan(123 / 180 * 3.14159) => -1.54  tan(123 / 180 * 3.14159) => -1.54
397  tan(321 / 180 * 3.14159) => -0.81  tan(321 / 180 * 3.14159) => -0.81
398  tan('x') => error  tan('x') => error
399    EOF
400    
401    cat > 20-missing.expr <<'EOF'
402  # FIXME: a variable name as the argument to SYSMIS is a special case  # FIXME: a variable name as the argument to SYSMIS is a special case
403  # that we don't yet test.  We also can't test VALUE this way.  # that we don't yet test.  We also can't test VALUE this way.
404  missing(10) => false  missing(10) => false
# Line 382  sysmis($sysmis) => true Line 421  sysmis($sysmis) => true
421  sysmis(asin(1.01)) => true  sysmis(asin(1.01)) => true
422  sysmis(asin(.5)) => false  sysmis(asin(.5)) => false
423  sysmis('    ') => error  sysmis('    ') => error
424    EOF
425    
426    cat > 21-any.expr <<'EOF'
427  any($sysmis, 1, $sysmis, 3) => sysmis  any($sysmis, 1, $sysmis, 3) => sysmis
428  any(1, 1, 2, 3) => true  any(1, 1, 2, 3) => true
429  any(2, 1, 2, 3) => true  any(2, 1, 2, 3) => true
# Line 414  any(a, 'b', 'c', 'd') => error Line 455  any(a, 'b', 'c', 'd') => error
455  any('a', b, 'c', 'd') => error  any('a', b, 'c', 'd') => error
456  any('a', 'b', c, 'd') => error  any('a', 'b', c, 'd') => error
457  any('a', 'b', 'c', d) => error  any('a', 'b', 'c', d) => error
458    EOF
459    
460    cat > 22-range.expr <<'EOF'
461  range(5, 1, 10) => true  range(5, 1, 10) => true
462  range(1, 1, 10) => true  range(1, 1, 10) => true
463  range(10, 1, 10) => true  range(10, 1, 10) => true
# Line 471  range('1', '2', '3', '4', '5', '6') => e Line 514  range('1', '2', '3', '4', '5', '6') => e
514  range(1, '2', '3') => error  range(1, '2', '3') => error
515  range('1', 2, '3') => error  range('1', 2, '3') => error
516  range('1', '2', 3) => error  range('1', '2', 3) => error
517    EOF
518    
519  cfvar(1, 2, 3, 4, 5) => 0.53  cat > 23-max-min.expr <<'EOF'
 cfvar(1, $sysmis, 2, 3, $sysmis, 4, 5) => 0.53  
 cfvar(1, 2) => 0.47  
 cfvar(1) => error  
 cfvar(1, $sysmis) => sysmis  
 cfvar(1, 2, 3, $sysmis) => 0.50  
 cfvar.4(1, 2, 3, $sysmis) => sysmis  
 cfvar.4(1, 2, 3) => error  
 cfvar('x') => error  
 cfvar('x', 1, 2, 3) => error  
   
520  max(1, 2, 3, 4, 5) => 5.00  max(1, 2, 3, 4, 5) => 5.00
521  max(1, $sysmis, 2, 3, $sysmis, 4, 5) => 5.00  max(1, $sysmis, 2, 3, $sysmis, 4, 5) => 5.00
522  max(1, 2) => 2.00  max(1, 2) => 2.00
# Line 497  max("2", "3", "5", "1", "4") => "5" Line 531  max("2", "3", "5", "1", "4") => "5"
531  max("1", "2") => "2"  max("1", "2") => "2"
532  max("1") => "1"  max("1") => "1"
533    
 mean(1, 2, 3, 4, 5) => 3.00  
 mean(1, $sysmis, 2, 3, $sysmis, 4, 5) => 3.00  
 mean(1, 2) => 1.50  
 mean() => error  
 mean(1) => 1.00  
 mean(1, $sysmis) => 1.00  
 mean(1, 2, 3, $sysmis) => 2.00  
 mean.4(1, 2, 3, $sysmis) => sysmis  
 mean.4(1, 2, 3) => error  
   
534  min(1, 2, 3, 4, 5) => 1.00  min(1, 2, 3, 4, 5) => 1.00
535  min(1, $sysmis, 2, 3, $sysmis, 4, 5) => 1.00  min(1, $sysmis, 2, 3, $sysmis, 4, 5) => 1.00
536  min(1, 2) => 1.00  min(1, 2) => 1.00
# Line 520  min.4(1, 2, 3) => error Line 544  min.4(1, 2, 3) => error
544  min("2", "3", "5", "1", "4") => "1"  min("2", "3", "5", "1", "4") => "1"
545  min("1", "2") => "1"  min("1", "2") => "1"
546  min("1") => "1"  min("1") => "1"
547    EOF
548    
549    cat > 24-moments.expr <<'EOF'
550    cfvar(1, 2, 3, 4, 5) => 0.53
551    cfvar(1, $sysmis, 2, 3, $sysmis, 4, 5) => 0.53
552    cfvar(1, 2) => 0.47
553    cfvar(1) => error
554    cfvar(1, $sysmis) => sysmis
555    cfvar(1, 2, 3, $sysmis) => 0.50
556    cfvar.4(1, 2, 3, $sysmis) => sysmis
557    cfvar.4(1, 2, 3) => error
558    cfvar('x') => error
559    cfvar('x', 1, 2, 3) => error
560    
561    mean(1, 2, 3, 4, 5) => 3.00
562    mean(1, $sysmis, 2, 3, $sysmis, 4, 5) => 3.00
563    mean(1, 2) => 1.50
564    mean() => error
565    mean(1) => 1.00
566    mean(1, $sysmis) => 1.00
567    mean(1, 2, 3, $sysmis) => 2.00
568    mean.4(1, 2, 3, $sysmis) => sysmis
569    mean.4(1, 2, 3) => error
570    
571  sd(1, 2, 3, 4, 5) => 1.58  sd(1, 2, 3, 4, 5) => 1.58
572  sd(1, $sysmis, 2, 3, $sysmis, 4, 5) => 1.58  sd(1, $sysmis, 2, 3, $sysmis, 4, 5) => 1.58
# Line 552  variance.4(1, 2, 3, $sysmis) => sysmis Line 599  variance.4(1, 2, 3, $sysmis) => sysmis
599  variance.4(1, 2, 3) => error  variance.4(1, 2, 3) => error
600  variance('x') => error  variance('x') => error
601  variance('x', 1, 2, 3) => error  variance('x', 1, 2, 3) => error
602    EOF
603    
604    cat > 25-concat.expr <<'EOF'
605  concat('') => ""  concat('') => ""
606  concat('a', 'b') => "ab"  concat('a', 'b') => "ab"
607  concat('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') => "abcdefgh"  concat('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') => "abcdefgh"
608  concat('abcdefgh', 'ijklmnopq') => "abcdefghijklmnopq"  concat('abcdefgh', 'ijklmnopq') => "abcdefghijklmnopq"
609  concat('a', 1) => error  concat('a', 1) => error
610  concat(1, 2) => error  concat(1, 2) => error
611    EOF
612    
613    cat > 26-index.expr <<'EOF'
614  index('abcbcde', 'bc') => 2.00  index('abcbcde', 'bc') => 2.00
615  index('abcbcde', 'bcd') => 4.00  index('abcbcde', 'bcd') => 4.00
616  index('abcbcde', 'bcbc') => 2.00  index('abcbcde', 'bcbc') => 2.00
# Line 588  index('abcbcde', 'abc', 1) => 1.00 Line 639  index('abcbcde', 'abc', 1) => 1.00
639  index('abcbcde', 'bccb', 2) => 2.00  index('abcbcde', 'bccb', 2) => 2.00
640  index('abcbcde', 'bcbc', 2) => 2.00  index('abcbcde', 'bcbc', 2) => 2.00
641  index('abcbcde', 'bcbc', $sysmis) => sysmis  index('abcbcde', 'bcbc', $sysmis) => sysmis
642    EOF
643    
644    cat > 27-rindex.expr <<'EOF'
645  rindex('abcbcde', 'bc') => 4.00  rindex('abcbcde', 'bc') => 4.00
646  rindex('abcbcde', 'bcd') => 4.00  rindex('abcbcde', 'bcd') => 4.00
647  rindex('abcbcde', 'bcbc') => 2.00  rindex('abcbcde', 'bcbc') => 2.00
# Line 624  rindex(1, 'bcdfkjl', 2) => error Line 677  rindex(1, 'bcdfkjl', 2) => error
677  rindex('aksj', 2, 2) => error  rindex('aksj', 2, 2) => error
678  rindex(1, 2, 3) => error  rindex(1, 2, 3) => error
679  rindex(1, 2, '3') => error  rindex(1, 2, '3') => error
680    EOF
681    
682    cat > 28-length.expr <<'EOF'
683  length('') => 0.00  length('') => 0.00
684  length('a') => 1.00  length('a') => 1.00
685  length('xy') => 2.00  length('xy') => 2.00
# Line 632  length('adsf    ') => 8.00 Line 687  length('adsf    ') => 8.00
687  length('abcdefghijkl') => 12.00  length('abcdefghijkl') => 12.00
688  length(0) => error  length(0) => error
689  length($sysmis) => error  length($sysmis) => error
690    EOF
691    
692  lower('ABCDEFGHIJKLMNOPQRSTUVWXYZ!@%&*(089') => "abcdefghijklmnopqrstuvwxyz!@%&*(089"  cat > 29-pad.expr <<'EOF'
 lower('') => ""  
 lower(1) => error  
   
693  lpad('abc', -1) => ""  lpad('abc', -1) => ""
694  lpad('abc', 0) => "abc"  lpad('abc', 0) => "abc"
695  lpad('abc', 2) => "abc"  lpad('abc', 2) => "abc"
# Line 660  lpad('abc', 'def', ' ') => error Line 713  lpad('abc', 'def', ' ') => error
713  lpad('x', 5, 0) => error  lpad('x', 5, 0) => error
714  lpad('x', 5, 2) => error  lpad('x', 5, 2) => error
715    
 number("123", f3.0) => 123.00  
 number(" 123", f3.0) => 12.00  
 number("123", f3.1) => 12.30  
 number("   ", f3.1) => sysmis  
   
 ltrim('   abc') => "abc"  
 rtrim('   abc   ') => "   abc"  
 ltrim('abc') => "abc"  
 ltrim(' abc') => "      abc"  
 ltrim('    ') => ""  
 ltrim('') => ""  
 ltrim(8) => error  
 ltrim('***abc', '*') => "abc"  
 ltrim('abc', '*') => "abc"  
 ltrim('*abc', '*') => "abc"  
 ltrim('', '*') => ""  
 ltrim(8, '*') => error  
 ltrim(' x', 8) => error  
 ltrim(8, 9) => error  
   
716  rpad('abc', -1) => ""  rpad('abc', -1) => ""
717  rpad('abc', 0) => "abc"  rpad('abc', 0) => "abc"
718  rpad('abc', 2) => "abc"  rpad('abc', 2) => "abc"
# Line 702  rpad(0, 10, ' ') => error Line 735  rpad(0, 10, ' ') => error
735  rpad('abc', 'def', ' ') => error  rpad('abc', 'def', ' ') => error
736  rpad('x', 5, 0) => error  rpad('x', 5, 0) => error
737  rpad('x', 5, 2) => error  rpad('x', 5, 2) => error
738    EOF
739    
740    cat > 30-num-str.expr <<'EOF'
741    number("123", f3.0) => 123.00
742    number(" 123", f3.0) => 12.00
743    number("123", f3.1) => 12.30
744    number("   ", f3.1) => sysmis
745    
746    string(123.56, f5.1) => "123.6"
747    string($sysmis, f5.1) => "   . "
748    string("abc", A5) => error
749    EOF
750    
751    cat > 31-trim.expr <<'EOF'
752    ltrim('   abc') => "abc"
753    rtrim('   abc   ') => "   abc"
754    ltrim('abc') => "abc"
755    ltrim(' abc') => "      abc"
756    ltrim('    ') => ""
757    ltrim('') => ""
758    ltrim(8) => error
759    ltrim('***abc', '*') => "abc"
760    ltrim('abc', '*') => "abc"
761    ltrim('*abc', '*') => "abc"
762    ltrim('', '*') => ""
763    ltrim(8, '*') => error
764    ltrim(' x', 8) => error
765    ltrim(8, 9) => error
766    
767  rtrim('abc   ') => "abc"  rtrim('abc   ') => "abc"
768  rtrim('   abc   ') => "   abc"  rtrim('   abc   ') => "   abc"
# Line 717  rtrim('', '*') => "" Line 778  rtrim('', '*') => ""
778  rtrim(8, '*') => error  rtrim(8, '*') => error
779  rtrim(' x', 8) => error  rtrim(' x', 8) => error
780  rtrim(8, 9) => error  rtrim(8, 9) => error
781    EOF
782    
783  string(123.56, f5.1) => "123.6"  cat > 32-substr.expr <<'EOF'
 string($sysmis, f5.1) => "   . "  
 string("abc", A5) => error  
   
784  substr('abcdefgh', -5) => ""  substr('abcdefgh', -5) => ""
785  substr('abcdefgh', 0) => ""  substr('abcdefgh', 0) => ""
786  substr('abcdefgh', 1) => "abcdefgh"  substr('abcdefgh', 1) => "abcdefgh"
# Line 766  substr('abcd', 'abc', 0) => error Line 825  substr('abcd', 'abc', 0) => error
825  substr('abcd', 'abc', 'j') => error  substr('abcd', 'abc', 'j') => error
826  substr(0, 'abc', 4) => error  substr(0, 'abc', 4) => error
827  substr(0, 'abc', 'k') => error  substr(0, 'abc', 'k') => error
828    EOF
829    
830    cat > 33-case.expr <<'EOF'
831    lower('ABCDEFGHIJKLMNOPQRSTUVWXYZ!@%&*(089') => "abcdefghijklmnopqrstuvwxyz!@%&*(089"
832    lower('') => ""
833    lower(1) => error
834    
835  upcase('abcdefghijklmnopqrstuvwxyz!@%&*(089') => "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@%&*(089"  upcase('abcdefghijklmnopqrstuvwxyz!@%&*(089') => "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@%&*(089"
836  upcase('') => ""  upcase('') => ""
837  upcase(1) => error  upcase(1) => error
838    EOF
839    
840    cat > 34-time.expr <<'EOF'
841  time.days(1) => 86400.00  time.days(1) => 86400.00
842  time.days(-1) => -86400.00  time.days(-1) => -86400.00
843  time.days(0.5) => 43200.00  time.days(0.5) => 43200.00
# Line 790  time.hms($sysmis, $sysmis, 7) => sysmis Line 857  time.hms($sysmis, $sysmis, 7) => sysmis
857  time.hms(5, $sysmis, $sysmis) => sysmis  time.hms(5, $sysmis, $sysmis) => sysmis
858  time.hms($sysmis, $sysmis, 7) => sysmis  time.hms($sysmis, $sysmis, 7) => sysmis
859  time.hms($sysmis, $sysmis, $sysmis) => sysmis  time.hms($sysmis, $sysmis, $sysmis) => sysmis
860    EOF
861    
862    cat > 35-ctime.expr <<'EOF'
863  ctime.days(106272) => 1.23  ctime.days(106272) => 1.23
864  ctime.hours(106272) => 29.52  ctime.hours(106272) => 29.52
865  ctime.minutes(106272) => 1771.20  ctime.minutes(106272) => 1771.20
# Line 897  date.wkyr('a','b') => error Line 966  date.wkyr('a','b') => error
966  ctime.days(date.yrday(2000,1)) => 152385.00  ctime.days(date.yrday(2000,1)) => 152385.00
967  ctime.days(date.yrday(2000,100)) => 152484.00  ctime.days(date.yrday(2000,100)) => 152484.00
968  ctime.days(date.yrday(2000,253)) => 152637.00  ctime.days(date.yrday(2000,253)) => 152637.00
969  ctime.days(date.yrday(2000,500)) => 152884.00  ctime.days(date.yrday(2000,500)) => sysmis
970  ctime.days(date.yrday(2000,-100)) => 152284.00  ctime.days(date.yrday(2000,-100)) => sysmis
971  ctime.days(date.yrday(1999,$sysmis)) => sysmis  ctime.days(date.yrday(1999,$sysmis)) => sysmis
972  ctime.days(date.yrday($sysmis,1)) => sysmis  ctime.days(date.yrday($sysmis,1)) => sysmis
973  ctime.days(date.yrday($sysmis,$sysmis)) => sysmis  ctime.days(date.yrday($sysmis,$sysmis)) => sysmis
974  date.yrday(1999,'a') => error  date.yrday(1999,'a') => error
975  date.yrday('a',5) => error  date.yrday('a',5) => error
976  date.yrday('a','b') => error  date.yrday('a','b') => error
977    EOF
978    
979  # FIXME: XDATE.* functions  # FIXME: XDATE.* functions
980  # FIXME: LAG  # FIXME: LAG
981  # FIXME: YRMODA  # FIXME: YRMODA
 EOF  
 if [ $? -ne 0 ] ; then no_result ; fi  
   
 activity="create optimizing input"  
 echo 'set mxwarn 1000.  
 set mxerr 1000.' > $TEMPDIR/expr-opt.stat  
 sed < $TEMPDIR/expr-list >> $TEMPDIR/expr-opt.stat \  
         -e 's#^\(.*\) => \(.*\)$#DEBUG EVALUATE/\1.#'  
 if [ $? -ne 0 ] ; then no_result ; fi  
   
 activity="run optimizing program"  
 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii \  
          $TEMPDIR/expr-opt.stat >$TEMPDIR/expr-opt.err 2> $TEMPDIR/expr-opt.out  
   
 activity="compare optimizing output"  
 diff -B -b $TEMPDIR/expr-list $TEMPDIR/expr-opt.out  
 if [ $? -ne 0 ] ; then fail ; fi  
   
 activity="create non-optimizing input"  
 echo 'set mxwarn 1000.  
 set mxerr 1000.' > $TEMPDIR/expr-noopt.stat  
 sed < $TEMPDIR/expr-list >> $TEMPDIR/expr-noopt.stat \  
         -e 's#^\(.*\) => \(.*\)$#DEBUG EVALUATE NOOPTIMIZE/\1.#'  
 if [ $? -ne 0 ] ; then no_result ; fi  
   
 activity="run non-optimizing program"  
 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii \  
         $TEMPDIR/expr-noopt.stat >$TEMPDIR/expr-noopt.err 2> $TEMPDIR/expr-noopt.out  
   
 activity="compare non-optimizing output"  
 diff -B -b $TEMPDIR/expr-list $TEMPDIR/expr-noopt.out  
 if [ $? -ne 0 ] ; then fail ; fi  
982    
983    printf "expressions..."
984    for d in *.expr; do
985        base=`echo $d | sed 's/\.expr$//'`
986    
987        # Remove comments.
988        sed -ne 's/#.*//;/^[        ]*$/!p' < $base.expr > $base.clean
989        if [ $? -ne 0 ] ; then no_result ; fi
990    
991        for optimize in opt noopt; do
992            if test optimize = opt; then
993                opt_kw=''
994            else
995                opt_kw=' NOOPTIMIZE'
996            fi
997            
998            # Translate to DEBUG EVALUATE commands.
999            activity="$base, $optimize: create input"
1000            sed 's#^\(.*\) => \(.*\)$#DEBUG EVALUATE'"$opt_kw"'/\1.#' \
1001                < $base.clean > $base.$optimize.stat
1002            if [ $? -ne 0 ] ; then no_result ; fi
1003    
1004            # Run.
1005            activity="$base, $optimize: run program"
1006            $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii \
1007                $base.$optimize.stat > $base.$optimize.err 2> $base.$optimize.out
1008    
1009            # Compare.
1010            activity="$base, $optimize: compare output"
1011            diff -B -b $base.clean $base.$optimize.out
1012            if [ $? -ne 0 ] ; then fail ; fi
1013        done
1014        num=`echo $d | sed 's/-.*//'`
1015        printf " $num"
1016    done
1017    printf ' ...done\n'
1018  pass  pass

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26