Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / language / stats / sort-cases.at
index d06f2b2901e7ab33bb32111ee43b0b1c14369000..4f6492d964b932868f9517bad8505f36b5ffa057 100644 (file)
@@ -1,3 +1,19 @@
+dnl PSPP - a program for statistical analysis.
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+dnl 
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+dnl
 AT_BANNER([SORT CASES])
 
 m4_divert_push([PREPARE_TESTS])
@@ -46,7 +62,7 @@ m4_define([SORT_CASES_TEST],
    AT_CAPTURE_FILE([sort-cases.sps])
    AT_DATA([sort-cases.sps], [dnl
 DATA LIST LIST NOTABLE FILE='data.txt'/x y (F8).
-SORT BY x[]m4_if([$3], [], [], [/BUFFERS=$3]).
+SORT CASES BY x[]m4_if([$3], [], [], [/BUFFERS=$3]).
 PRINT OUTFILE='output.txt'/x y.
 EXECUTE.
 ])
@@ -80,3 +96,51 @@ SORT_CASES_TEST(10000, 5, 500)
 
 SORT_CASES_TEST(50000, 1)
 
+dnl Bug #33089 caused SORT CASES to delete filtered cases permanently.
+AT_SETUP([SORT CASES preserves filtered cases])
+AT_DATA([sort-cases.sps], [dnl
+DATA LIST FREE /x.
+BEGIN DATA.
+5 4 3 2 1 0
+END DATA.
+COMPUTE mod2 = MOD(x, 2).
+LIST.
+FILTER BY mod2.
+LIST.
+SORT CASES BY x.
+LIST.
+FILTER OFF.
+LIST.
+])
+AT_CHECK([pspp -O format=csv sort-cases.sps], [0], [dnl
+Table: Data List
+x,mod2
+5.00,1.00
+4.00,.00
+3.00,1.00
+2.00,.00
+1.00,1.00
+.00,.00
+
+Table: Data List
+x,mod2
+5.00,1.00
+3.00,1.00
+1.00,1.00
+
+Table: Data List
+x,mod2
+1.00,1.00
+3.00,1.00
+5.00,1.00
+
+Table: Data List
+x,mod2
+.00,.00
+1.00,1.00
+2.00,.00
+3.00,1.00
+4.00,.00
+5.00,1.00
+])
+AT_CLEANUP