Commit | Line | Data |
---|---|---|
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.) | |
7 | strip_first_line () | |
8 | { | |
9 | read line | |
10 | while read line | |
11 | do | |
12 | echo "$line" | |
13 | done | |
14 | } | |
15 | ||
2dea6a4d BT |
16 | snarf () |
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 | ||
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;" | |
fd029c35 BT |
34 | snarf_test "c\n^^d^:^\ne" "d;" |
35 | snarf_test "f^^g^:^h" "g;" | |
36 | snarf_test "^^i^:^j^^k^:^" "i;k;" | |
95c1cfb5 BT |
37 | snarf_test "l^^m" "" |
38 | snarf_test "n^:^o" "" |