Merge commit 'fb7dd00169304a5922838e4d2f25253640a35def'
[bpt/guile.git] / test-suite / standalone / test-guile-snarf
1 #!/bin/sh
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.)
7 strip_first_line ()
8 {
9 read line
10 while read line
11 do
12 echo "$line"
13 done
14 }
15
16 snarf ()
17 {
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'
21 }
22
23 snarf_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
32 snarf_test "^^a^:^" "a;"
33 snarf_test " ^ ^ b ^ : ^ " "b;"
34 snarf_test "c\n^^d^:^\ne" "d;"
35 snarf_test "f^^g^:^h" "g;"
36 snarf_test "^^i^:^j^^k^:^" "i;k;"
37 snarf_test "l^^m" ""
38 snarf_test "n^:^o" ""