test-guile-snarf 819 B

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