summaryrefslogtreecommitdiff
path: root/modules/shadow.test
blob: c8952b59b8e11955b62ba5ddbd422c905adce9c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh

# shadow.test is part of the GNU m4 testsuite

. ${srcdir}/defs
. ../../tests/config.sh

# cannot perform test without --with-modules
# test -z "$WITH_MODULES" && exit 77

cat ${srcdir}/shadow.m4 >in

cat <<'EOF' >ok
# no modules loaded yet
test
shadow

# define our own macros for `test' and `shadow'


local::test
local::shadow

# save our local `shadow' macro until the Shadow module is unloaded


# module Shadow defines `shadow' and `test' macros
Shadow module loaded.


Shadow::test called.
Shadow::shadow called.

# save the definition of `test' from the Shadow module


# module Test also defines a `test' macro
Test module loaded. 


Test module called.
Shadow::shadow called.

# Reloading Shadow shouldn't affect anything



Test module called.
Shadow::shadow called.

# Unloading Test will not unshadow the test definition in Shadow without
# some macro magic





Shadow::test called.
Shadow::shadow called.

# Unloading Shadow once has no effect (we loaded it twice)



Shadow::test called.
Shadow::shadow called.

# Unloading Shadow again will revert to copying `test' and the locally
# pushed `shadow' macro.

test
local::shadow
EOF

cat <<'EOF' >okerr
test:	<test>
shadow:	<shadow>
test:	<test>
shadow:	<shadow>
test:	<test>
shadow:	<shadow>
test:	<test>
shadow:	<shadow>
test:	<test>
shadow:	<shadow>
EOF


M4PATH=$srcdir:$srcdir/../tests $M4 -M `cd $srcdir; pwd` -d in >out 2>err
sed -e "s,^[^:]*[lt-]*m4[.ex]*:,m4:," err >sederr && mv sederr err
$CMP -s out ok && $CMP -s err okerr