Some basic macros and tests work.
[pspp] / tests / language / control / define.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([DEFINE])
18
19 AT_SETUP([simple macro expansion])
20 AT_DATA([define.sps], [dnl
21 DEFINE !macro()
22 a b c d
23 e f g h.
24 i j k l
25 1,2,3,4.
26 5+6+7.
27 m(n,o).
28 "a" "b" "c" 'a' 'b' 'c'.
29 "x "" y".
30 !ENDDEFINE.
31 DEBUG EXPAND.
32 !macro()
33 ])
34 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
35 a b c d e f g h.
36 i j k l 1, 2, 3, 4.
37 5 + 6 + 7.
38 m(n, o).
39 "a" "b" "c" 'a' 'b' 'c'.
40 "x "" y".
41 ])
42 AT_CLEANUP
43
44 AT_SETUP([macro expansion with arguments])
45 AT_DATA([define.sps], [dnl
46 DEFINE !t1(!positional !tokens(1)) (!1) !ENDDEFINE.
47 DEFINE !t2(!positional !tokens(2)) (!1) !ENDDEFINE.
48 DEFINE !ce(!positional !charend('/')) (!1) !ENDDEFINE.
49 DEBUG EXPAND.
50 !t1 a.
51 !t1 b.
52 !t1 a b.
53
54 !t2 a b.
55 !t2 b c d.
56
57 !ce x y z/.
58 ])
59 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
60 (a)
61
62 (b)
63
64 (a)
65
66 (a b)
67
68 (b c)
69
70 (x y z)
71 ])
72 AT_CLEANUP