Merge branch 'stable-2.0'
[bpt/guile.git] / test-suite / standalone / test-guile-snarf
CommitLineData
2dea6a4d 1#!/bin/sh
25dc93dd
LC
2
3# Test the `guile-snarf' tool.
4
5# Strip the first line, like GNU `tail -n +2' does, but in a portable
6# way (`tail' on Solaris 10 doesn't support `-n +2' for instance.)
7strip_first_line ()
8{
9 read line
10 while read line
11 do
12 echo "$line"
13 done
14}
15
2dea6a4d
BT
16snarf ()
17{
25dc93dd
LC
18 # GNU cpp emits a comment on the first line, which shows what
19 # arguments it was passed. Strip this line.
20 echo "$1" | guile-snarf - | strip_first_line | tr -d ' \t\n'
2dea6a4d
BT
21}
22
23snarf_test ()
24{
25 x=`snarf "$1"`
26 if [ x"$x" != x"$2" ]; then
27 echo "Incorrect output: expected \"$2\", but got \"$x\""
28 exit 1
29 fi
30}
31
32snarf_test "^^a^:^" "a;"
33snarf_test " ^ ^ b ^ : ^ " "b;"
fd029c35
BT
34snarf_test "c\n^^d^:^\ne" "d;"
35snarf_test "f^^g^:^h" "g;"
36snarf_test "^^i^:^j^^k^:^" "i;k;"
95c1cfb5
BT
37snarf_test "l^^m" ""
38snarf_test "n^:^o" ""