+dnl PCOMPUTE needs to be an internal exception to omitting empty
+dnl categories, but the code didn't always implement that
+dnl properly. This test guards against regression.
+AT_SETUP([CTABLES interaction between EMPTY and PCOMPUTE])
+AT_CHECK([ln $top_srcdir/tests/language/commands/nhtsa.sav . || cp $top_srcdir/tests/language/commands/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+
+* Make sure that "Never" has no responses.
+SELECT IF qn1 <> 5.
+
+* This will include "% Not Drivers" even though it has a zero value,
+because it is explicitly specified. It will include "missing" and the
+"Not Drivers or Missing" subtotal, even though they are both zero,
+because we include empty values.
+CTABLES
+ /PCOMPUTE &all_drivers=EXPR([1 THRU 2] + [3 THRU 4])
+ /PPROPERTIES &all_drivers LABEL='All Drivers'
+ /PCOMPUTE &pct_never=EXPR([5] / ([1 THRU 2] + [3 THRU 4] + [5]) * 100)
+ /PPROPERTIES &pct_never LABEL='% Not Drivers' FORMAT=COUNT PCT40.1
+ /TABLE=qn1 BY qns3a
+ /CATEGORIES VARIABLES=qn1
+ [1 THRU 2, SUBTOTAL='Frequent Drivers',
+ 3 THRU 4, SUBTOTAL='Infrequent Drivers',
+ &all_drivers, 5, &pct_never,
+ MISSING, SUBTOTAL='Not Drivers or Missing'].
+
+* This will include "% Not Drivers" even though it has a zero value,
+because it is explicitly specified. It will omit "missing" and the
+"Not Drivers or Missing" subtotal because they are both zero and
+we have EMPTY=EXCLUDE.
+CTABLES
+ /PCOMPUTE &all_drivers=EXPR([1 THRU 2] + [3 THRU 4])
+ /PPROPERTIES &all_drivers LABEL='All Drivers'
+ /PCOMPUTE &pct_never=EXPR([5] / ([1 THRU 2] + [3 THRU 4] + [5]) * 100)
+ /PPROPERTIES &pct_never LABEL='% Not Drivers' FORMAT=COUNT PCT40.1
+ /TABLE=qn1 BY qns3a
+ /CATEGORIES VARIABLES=ALL EMPTY=EXCLUDE
+ /CATEGORIES VARIABLES=qn1
+ [1 THRU 2, SUBTOTAL='Frequent Drivers',
+ 3 THRU 4, SUBTOTAL='Infrequent Drivers',
+ &all_drivers, 5, &pct_never,
+ MISSING, SUBTOTAL='Not Drivers or Missing'].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭────────────────────────────────────────────────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├────────────────────────────────────────────────────────────────┼─────┼──────┤
+│ 1. How often do you usually drive a car or Every day │ 2305│ 2362│
+│other motor vehicle? Several days a week │ 440│ 834│
+│ Frequent Drivers │ 2745│ 3196│
+│ Once a week or less │ 125│ 236│
+│ Only certain times a│ 58│ 72│
+│ year │ │ │
+│ Infrequent Drivers │ 183│ 308│
+│ All Drivers │ 2928│ 3504│
+│ Never │ 0│ 0│
+│ % Not Drivers │ .0%│ .0%│
+│ Don't know │ 0│ 0│
+│ Refused │ 0│ 0│
+│ Not Drivers or │ 0│ 0│
+│ Missing │ │ │
+╰────────────────────────────────────────────────────────────────┴─────┴──────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├────────────────────────────────────────────────────────────────┼─────┼──────┤
+│ 1. How often do you usually drive a car or Every day │ 2305│ 2362│
+│other motor vehicle? Several days a week │ 440│ 834│
+│ Frequent Drivers │ 2745│ 3196│
+│ Once a week or less │ 125│ 236│
+│ Only certain times a│ 58│ 72│
+│ year │ │ │
+│ Infrequent Drivers │ 183│ 308│
+│ All Drivers │ 2928│ 3504│
+│ % Not Drivers │ .0%│ .0%│
+╰────────────────────────────────────────────────────────────────┴─────┴──────╯
+])
+AT_CLEANUP
+