PCOMPUTE works
[pspp] / tests / language / stats / ctables.at
index d6bfc8ac2581a0b1521db07cbfd54e660dfb2936..210a93e8707adb551fe551b7689438548518b756 100644 (file)
@@ -37,7 +37,11 @@ dnl   * MISSING.
 dnl - VLABELS.
 dnl - SMISSING.
 dnl - Test WEIGHT and adjustment weights.
-dnl - PCOMPUTE and PPROPERTIES.
+dnl - Test PCOMPUTE and PPROPERTIES.
+dnl - PCOMPUTE:
+dnl   * multi-dimensional
+dnl   * MISSING, OTHERNM
+dnl   * strings
 dnl - HIDESMALLCOUNTS.
 dnl - Are string ranges a thing?
 
@@ -805,3 +809,38 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
 ])
 AT_CLEANUP
+
+AT_SETUP([CTABLES PCOMPUTE])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+    /PCOMPUTE &x=EXPR([3] + [4])
+    /PCOMPUTE &y=EXPR([4] + [5])
+    /PPROPERTIES &x LABEL='3+4' HIDESOURCECATS=YES
+    /PPROPERTIES &y LABEL='4+5'
+    /TABLE=qn105ba BY qns1
+    /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL]
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
+                                                      Custom Tables
+╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
+│                                                         │ S1. Including yourself, how many members of this household │
+│                                                         │                    are age 16 or older?                    │
+│                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
+│                                                         │   1   │   2   │ Subtotal│   5   │   3+4  │  4+5 │ Subtotal │
+│                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
+│                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
+├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
+│105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     11│      81│    30│        92│
+│had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
+│Get stopped by the police?                    Very likely│    384│    552│      936│     14│     171│    65│       185│
+│                                              Somewhat   │    590│   1249│     1839│     20│     265│    92│       285│
+│                                              likely     │       │       │         │       │        │      │          │
+│                                              Somewhat   │    278│    647│      925│      6│     116│    38│       122│
+│                                              unlikely   │       │       │         │       │        │      │          │
+│                                              Very       │    141│    290│      431│      4│      59│    22│        63│
+│                                              unlikely   │       │       │         │       │        │      │          │
+╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
+])
+AT_CLEANUP