Text::Markdown::Discount
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
1.5 KiB

  1. __tests=0
  2. __passed=0
  3. __failed=0
  4. __title=
  5. title() {
  6. __title="$*"
  7. if [ "$VERBOSE" ]; then
  8. ./echo "$__title"
  9. else
  10. ./echo -n "$__title" \
  11. '.................................................................' | ./cols 54
  12. fi
  13. }
  14. summary() {
  15. if [ -z "$VERBOSE" ]; then
  16. if [ $__failed -eq 0 ]; then
  17. ./echo " OK"
  18. else
  19. ./echo
  20. ./echo "$1: $__tests tests; $__failed failed/$__passed passed"
  21. ./echo
  22. fi
  23. fi
  24. }
  25. try() {
  26. unset FLAGS
  27. while [ "$1" ]; do
  28. case "$1" in
  29. -*) FLAGS="$FLAGS $1"
  30. shift ;;
  31. *) break ;;
  32. esac
  33. done
  34. testcase=`./echo -n " $1" '........................................................' | ./cols 50`
  35. __tests=`expr $__tests + 1`
  36. test "$VERBOSE" && ./echo -n "$testcase"
  37. case "$2" in
  38. -t*) Q=`./markdown $FLAGS "$2"` ;;
  39. *) Q=`./echo "$2" | ./markdown $FLAGS` ;;
  40. esac
  41. if [ "$3" = "$Q" ]; then
  42. __passed=`expr $__passed + 1`
  43. test $VERBOSE && ./echo " ok"
  44. else
  45. __failed=`expr $__failed + 1`
  46. if [ -z "$VERBOSE" ]; then
  47. ./echo
  48. ./echo "$1"
  49. fi
  50. ./echo "source:"
  51. ./echo "$2" | sed -e 's/^/ /'
  52. ./echo "diff:"
  53. (./echo "$3" >> $$.w
  54. ./echo "$Q" >> $$.g
  55. diff $$.w $$.g ) | sed -e 's/^/ /'
  56. rm -f $$.w $$.g
  57. rc=1
  58. fi
  59. }
  60. match() {
  61. testcase=`./echo -n " $1" '........................................................' | ./cols 50`
  62. test $VERBOSE && ./echo -n "$testcase"
  63. if ./echo "$2" | ./markdown | grep "$3" >/dev/null; then
  64. test $VERBOSE && ./echo " ok"
  65. else
  66. if [ -z "$VERBOSE" ]; then
  67. ./echo
  68. ./echo "$testcase"
  69. fi
  70. rc=1
  71. fi
  72. }