a0b29d93a10a6ee83d4ab1b00dcb7f5778412e76
[pspp-builds.git] / tests / language / control / do-repeat.at
1 AT_BANNER([DO REPEAT])
2
3 AT_SETUP([DO REPEAT -- ordinary])
4 AT_DATA([do-repeat.sps], [dnl
5 DATA LIST NOTABLE /a 1.
6 BEGIN DATA.
7 0
8 END DATA.
9
10 DO REPEAT h = h0 TO h3 / x = 0 TO 3 / y = 8, 7.5, 6, 5.
11         COMPUTE h = x + y.
12 END REPEAT.
13
14 VECTOR v(6).
15 COMPUTE #idx = 0.
16 DO REPEAT i = 1 TO 2.
17         DO REPEAT j = 3 TO 5.
18                 COMPUTE #x = i + j.
19                 COMPUTE #idx = #idx + 1.
20                 COMPUTE v(#idx) = #x.
21         END REPEAT.
22 END REPEAT.
23
24 LIST.
25 ])
26 AT_CHECK([pspp -o pspp.csv do-repeat.sps])
27 AT_CHECK([cat pspp.csv], [0], [dnl
28 Table: Data List
29 a,h0,h1,h2,h3,v1,v2,v3,v4,v5,v6
30 0,8.00,8.50,8.00,8.00,4.00,5.00,6.00,5.00,6.00,7.00
31 ])
32 AT_CLEANUP
33
34 dnl This program tests for a bug that crashed PSPP given an empty DO
35 dnl REPEAT...END REPEAT block.  See bug #18407.
36 AT_SETUP([DO REPEAT -- empty])
37 AT_DATA([do-repeat.sps], [dnl
38 DATA LIST NOTABLE /a 1.
39 BEGIN DATA.
40 0
41 END DATA.
42
43 DO REPEAT h = a.
44 END REPEAT.
45 ])
46 AT_CHECK([pspp -o pspp.csv do-repeat.sps])
47 AT_CHECK([cat pspp.csv], [0], [dnl
48 ])
49 AT_CLEANUP
50
51 dnl This program tests for a bug that crashed PSPP when END REPEAT
52 dnl was missing.  See bug #31016.
53 AT_SETUP([DO REPEAT -- missing END REPEAT])
54 AT_DATA([do-repeat.sps], [dnl
55 DATA LIST NOTABLE /x 1.
56 DO REPEAT y = 1 TO 10.
57 ])
58 AT_CHECK([pspp -o pspp.csv do-repeat.sps], [1], [dnl
59 error: DO REPEAT: DO REPEAT without END REPEAT.
60 error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
61 ])
62 AT_CHECK([cat pspp.csv], [0], [dnl
63 error: DO REPEAT: DO REPEAT without END REPEAT.
64
65 error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
66 ])
67 AT_CLEANUP