FREQUENCIES: Fixed crash showing histograms of limited range.
[pspp] / tests / language / stats / frequencies.at
index cfd992a59d34282f08e40cd11922b5f4d96d9367..469ba82d185dd9c72199676b25528c55c93fd534 100644 (file)
@@ -70,7 +70,7 @@ Total,,4,100.0,100.0,
 AT_CLEANUP
 
 # Tests for a bug where PSPP would crash when a FREQUENCIES command
-# was used with the HTML output driver..
+# was used with the HTML output driver.
 AT_SETUP([FREQUENCIES HTML output crash])
 AT_DATA([frequencies.sps],
   [data list free /v1 v2.
@@ -105,7 +105,7 @@ AT_CHECK([test -s pspp.html])
 AT_CLEANUP
 
 # Tests for a bug which crashed PSPP when a piechart with too many
-# segments was requested..
+# segments was requested.
 AT_SETUP([FREQUENCIES pie chart crash])
 AT_DATA([frequencies.sps],
   [data list list /x * w *.
@@ -130,9 +130,7 @@ frequencies /x /format=notable /statistics=none
 ])
 # Cannot use the CSV driver for this because it does not output charts
 # at all.
-AT_CHECK([pspp frequencies.sps], [0],
-  [DATA LIST
-
+AT_CHECK([pspp frequencies.sps], [0], [dnl
 Reading free-form data from INLINE.
 +--------+------+
 |Variable|Format|
@@ -140,17 +138,56 @@ Reading free-form data from INLINE.
 |x       |F8.0  |
 |w       |F8.0  |
 +--------+------+
+])
+AT_CLEANUP
+
+dnl Check that histogram subcommand runs wihout crashing
+AT_SETUP([FREQUENCIES histogram crash])
+AT_DATA([frequencies.sps],
+  [data list notable list /x * w *.
+begin data.
+1  4
+34 10
+-9 15
+232 6
+11  4
+134 1
+9  5
+32 16
+-2 6
+2  16
+20  6
+end data.
 
-BEGIN DATA
+weight by w.
 
-WEIGHT
+frequencies /x 
+           /format=notable 
+           /statistics=none
+           /histogram=minimum(0) maximum(50) percent(5) normal.
+])
+# Cannot use the CSV driver for this because it does not output charts
+# at all.
+AT_CHECK([pspp -O format=pdf frequencies.sps], [0], [ignore])
+AT_CLEANUP
 
-FREQUENCIES
+# Tests for a bug which crashed PSPP when the median and a histogram
+# were both requested.
+AT_SETUP([FREQUENCIES median with histogram crash])
+AT_DATA([frequencies.sps], [dnl
+data list list notable /x.
+begin data.
+1
+end data.
+
+frequencies /x /histogram /STATISTICS=median.
 ])
+AT_CHECK([pspp -O format=csv frequencies.sps], [0], [ignore])
+dnl Ignore output - No crash test.
 AT_CLEANUP
 
 # Tests for a bug which caused FREQUENCIES following TEMPORARY to
-# crash (bug #11492)..
+# crash (bug #11492).
 AT_SETUP([FREQUENCIES crash after TEMPORARY])
 AT_DATA([frequencies.sps],
   [DATA LIST LIST /SEX (A1) X *.
@@ -419,6 +456,47 @@ Percentiles,0,1.00
 ])
 AT_CLEANUP
 
+dnl Data for this test case from Fabio Bordignon <bordignon@demos.it>.
+AT_SETUP([FREQUENCIES enhanced percentiles, weighted (3)])
+AT_DATA([frequencies.sps],
+  [DATA LIST LIST notable /X * F *.
+BEGIN DATA.
+1 7
+2 16
+3 12
+4 5
+END DATA.
+
+WEIGHT BY f.
+
+FREQUENCIES 
+       VAR=x
+       /PERCENTILES = 0 25 50 75 100.
+])
+AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
+Table: X
+Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent
+,1.00,7.00,17.50,17.50,17.50
+,2.00,16.00,40.00,40.00,57.50
+,3.00,12.00,30.00,30.00,87.50
+,4.00,5.00,12.50,12.50,100.00
+Total,,40.00,100.0,100.0,
+
+Table: X
+N,Valid,40.00
+,Missing,.00
+Mean,,2.38
+Std Dev,,.93
+Minimum,,1.00
+Maximum,,4.00
+Percentiles,0,1.00
+,25,2.00
+,50 (Median),2.00
+,75,3.00
+,100,4.00
+])
+AT_CLEANUP
+
 AT_SETUP([FREQUENCIES enhanced percentiles, weighted, missing values])
 AT_DATA([frequencies.sps],
   [DATA LIST LIST notable /X * F *.
@@ -438,6 +516,7 @@ FREQUENCIES
        VAR=x
        /PERCENTILES = 0 25 50 75 100.
 ])
+
 AT_CHECK([pspp -O format=csv frequencies.sps], [0],
   [Table: X
 Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent
@@ -462,3 +541,36 @@ Percentiles,0,1.00
 ,100,5.00
 ])
 AT_CLEANUP
+
+AT_SETUP([FREQUENCIES dichotomous histogram])
+AT_DATA([frequencies.sps], [dnl
+data list notable list /d4 *.
+begin data.
+0 
+0 
+0 
+1 
+0 
+0 
+0 
+0 
+1 
+0 
+0 
+0 
+0 
+0 
+1 
+2 
+0 
+end data.
+
+FREQUENCIES
+       /VARIABLES = d4
+       /FORMAT=AVALUE TABLE
+       /HISTOGRAM=NORMAL
+       .
+])
+
+AT_CHECK([pspp frequencies.sps], [0],  [ignore])
+AT_CLEANUP