blob: e31479149270aa1b1920ee47ddebc966b69aecba (
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
|
#!/bin/sh
# Test the `guile-snarf' tool.
# Strip the first line, like GNU `tail -n +2' does, but in a portable
# way (`tail' on Solaris 10 doesn't support `-n +2' for instance.)
strip_first_line ()
{
read line
while read line
do
echo "$line"
done
}
snarf ()
{
# GNU cpp emits a comment on the first line, which shows what
# arguments it was passed. Strip this line.
echo "$1" | guile-snarf - | strip_first_line | tr -d ' \t\n'
}
snarf_test ()
{
x=`snarf "$1"`
if [ x"$x" != x"$2" ]; then
echo "Incorrect output: expected \"$2\", but got \"$x\""
exit 1
fi
}
snarf_test "^^a^:^" "a;"
snarf_test " ^ ^ b ^ : ^ " "b;"
snarf_test "c\n^^d^:^\ne" "d;"
snarf_test "f^^g^:^h" "g;"
snarf_test "^^i^:^j^^k^:^" "i;k;"
snarf_test "l^^m" ""
snarf_test "n^:^o" ""
|