diff --git a/tests/autolink.t b/tests/autolink.t index a471fea..b19dcb3 100644 --- a/tests/autolink.t +++ b/tests/autolink.t @@ -1,28 +1,8 @@ -./echo 'Reddit-style automatic links' +. tests/functions.sh + +title 'Reddit-style automatic links' rc=0 -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try -fautolink 'single link' \ 'http://www.pell.portland.or.us/~orc/Code/discount' \ '

http://www.pell.portland.or.us/~orc/Code/discount

' @@ -43,4 +23,5 @@ try -fautolink 'parenthesised (url)' \ try -fautolink 'token with trailing @' 'orc@' '

orc@

' +summary $0 exit $rc diff --git a/tests/automatic.t b/tests/automatic.t index 89c3e6a..2d91032 100644 --- a/tests/automatic.t +++ b/tests/automatic.t @@ -1,41 +1,10 @@ -./echo "automatic links" +. tests/functions.sh + +title "automatic links" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - -match() { - ./echo -n " $1" '..................................' | ./cols 36 - - if ./echo "$2" | ./markdown | grep "$3" >/dev/null; then - ./echo " ok" - else - ./echo " FAILED" - rc=1 - fi -} - try 'http url' '' '

http://here

' try 'ftp url' '' '

ftp://here

' match '' '' '' '' '' '' '' '' 'foo

' @@ -31,5 +12,5 @@ try -fautolink 'autolink url with trailing \' \ 'http://a.com/\' \ '

http://a.com/\

' - +summary $0 exit $rc diff --git a/tests/callbacks.t b/tests/callbacks.t index 2f27988..28217bb 100644 --- a/tests/callbacks.t +++ b/tests/callbacks.t @@ -1,30 +1,10 @@ -./echo "callbacks" +. tests/functions.sh + +title "callbacks" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try -bZZZ 'url modification' \ '[a](/b)' \ '

a

' @@ -33,4 +13,5 @@ try -EZZZ 'additional flags' \ '[a](/b)' \ '

a

' +summary $0 exit $rc diff --git a/tests/code.t b/tests/code.t index ed460f9..821055c 100644 --- a/tests/code.t +++ b/tests/code.t @@ -1,30 +1,10 @@ -./echo "code blocks" +. tests/functions.sh + +title "code blocks" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'format for code block html' \ ' this is code' \ @@ -36,4 +16,5 @@ try 'unclosed single backtick' '`hi there' '

`hi there

' try 'unclosed double backtick' '``hi there' '

``hi there

' try 'remove space around code' '`` hi there ``' '

hi there

' +summary $0 exit $rc diff --git a/tests/compat.t b/tests/compat.t index 2ce7a14..f3256c1 100644 --- a/tests/compat.t +++ b/tests/compat.t @@ -1,29 +1,10 @@ -./echo "markdown 1.0 compatability" +. tests/functions.sh + +title "markdown 1.0 compatability" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - LINKY='[this] is a test [this]: /this' @@ -44,4 +25,5 @@ try -f1.0 'trailing whitespace (-f1.0)' "$WHITESPACE" '
white space''
 and more
 
' +summary $0 exit $rc diff --git a/tests/crash.t b/tests/crash.t index c0443ee..b553ce5 100644 --- a/tests/crash.t +++ b/tests/crash.t @@ -1,57 +1,30 @@ -./echo "crashes" +. tests/functions.sh + +title "crashes" rc=0 MARKDOWN_FLAGS= -./echo -n ' zero-length input ................ ' +try 'zero-length input' '' '' -if ./markdown < /dev/null >/dev/null; then - ./echo "ok" -else - ./echo "FAILED" - rc=1 -fi +try 'hanging quote in list' \ +' * > this should not die -./echo -n ' hanging quote in list ............ ' +no.' \ +'
    +
  • this should not die

  • +
-./markdown >/dev/null 2>/dev/null << EOF - * > this should not die -no. -EOF +

no.

' -if [ "$?" -eq 0 ]; then - ./echo "ok" -else - ./echo "FAILED" - rc=1 -fi +try 'dangling list item' ' - ' \ +'
    +
  • +
' -./echo -n ' dangling list item ............... ' - -if ./echo ' - ' | ./markdown >/dev/null 2>/dev/null; then - ./echo "ok" -else - ./echo "FAILED" - rc=1 -fi - -./echo -n ' empty []() with baseurl .......... ' - -if ./markdown -bHOHO -s '[]()' >/dev/null 2>/dev/null; then - ./echo "ok" -else - ./echo "FAILED" - rc=1 -fi - -./echo -n ' unclosed html block .............. ' - -if ./echo '/dev/null 2>/dev/null; then - ./echo 'ok' -else - ./echo "FAILED" - rc=1 -fi +try -bHOHO 'empty []() with baseurl' '[]()' '

' +try 'unclosed html block' '
/dev/null || exit 0 -./echo "%div% blocks" +. tests/functions.sh + +title "%div% blocks" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'simple >%div% block' \ '>%this% this this' \ @@ -63,5 +43,5 @@ more' \

more

' - +summary $0 exit $rc diff --git a/tests/dl.t b/tests/dl.t index 4c3a53a..b912f67 100644 --- a/tests/dl.t +++ b/tests/dl.t @@ -1,29 +1,10 @@ -./echo "definition lists" +. tests/functions.sh + +title "definition lists" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - SRC=' =this= is an ugly @@ -66,4 +47,5 @@ else fi +summary $0 exit $rc diff --git a/tests/emphasis.t b/tests/emphasis.t index 60e631f..94f7b04 100644 --- a/tests/emphasis.t +++ b/tests/emphasis.t @@ -1,30 +1,10 @@ -./echo "emphasis" +. tests/functions.sh + +title "emphasis" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - - try '*hi* -> hi' '*hi*' '

hi

' try '* -> *' 'A * A' '

A * A

' try -fstrict '***A**B*' '***A**B*' '

AB

' @@ -37,4 +17,5 @@ if ./markdown -V | grep RELAXED >/dev/null; then try -fstrict '_A_B with -fstrict' '_A_B' '

AB

' fi +summary $0 exit $rc diff --git a/tests/flow.t b/tests/flow.t index 3541727..44cf53a 100644 --- a/tests/flow.t +++ b/tests/flow.t @@ -1,30 +1,10 @@ -./echo "paragraph flow" +. tests/functions.sh + +title "paragraph flow" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'header followed by paragraph' \ '###Hello, sailor### And how are you today?' \ @@ -49,4 +29,5 @@ try 'two lists punctuated with a HR' \
  • C
  • ' +summary $0 exit $rc diff --git a/tests/footnotes.t b/tests/footnotes.t index 2fa9e94..2c923b0 100644 --- a/tests/footnotes.t +++ b/tests/footnotes.t @@ -1,29 +1,10 @@ -./echo "footnotes" +. tests/functions.sh + +title "footnotes" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'a line with multiple []s' '[a][] [b][]:' '

    [a][] [b][]:

    ' try 'a valid footnote' \ '[alink][] @@ -31,4 +12,5 @@ try 'a valid footnote' \ [alink]: link_me' \ '

    alink

    ' +summary $0 exit $rc diff --git a/tests/functions.sh b/tests/functions.sh new file mode 100644 index 0000000..745cc80 --- /dev/null +++ b/tests/functions.sh @@ -0,0 +1,77 @@ +__tests=0 +__passed=0 +__failed=0 +__title= + +title() { + __title="$*" + if [ "$VERBOSE" ]; then + ./echo "$__title" + else + ./echo -n "$__title" \ +'.................................................................' | ./cols 54 + fi +} + + +summary() { + if [ -z "$VERBOSE" ]; then + if [ $__failed -eq 0 ]; then + ./echo " OK" + else + ./echo + ./echo "$1: $__tests tests; $__failed failed/$__passed passed" + ./echo + fi + fi +} + + +try() { + unset FLAGS + case "$1" in + -*) FLAGS=$1 + shift ;; + esac + + testcase=`./echo -n " $1" '..................................' | ./cols 36` + __tests=`expr $__tests + 1` + + + test "$VERBOSE" && ./echo -n "$testcase" + + case "$2" in + -t*) Q=`./markdown $FLAGS "$2"` ;; + *) Q=`./echo "$2" | ./markdown $FLAGS` ;; + esac + + if [ "$3" = "$Q" ]; then + __passed=`expr $__passed + 1` + test $VERBOSE && ./echo " ok" + else + __failed=`expr $__failed + 1` + if [ -z "$VERBOSE" ]; then + ./echo + ./echo "$1" + fi + ./echo "wanted: $3" + ./echo "got : $Q" + rc=1 + fi +} + +match() { + testcase=`./echo -n " $1" '..................................' | ./cols 36` + + test $VERBOSE && ./echo -n "$testcase" + + if ./echo "$2" | ./markdown | grep "$3" >/dev/null; then + test $VERBOSE && ./echo " ok" + else + if [ -z "$VERBOSE" ]; then + ./echo + ./echo "$testcase" + fi + rc=1 + fi +} diff --git a/tests/header.t b/tests/header.t index aaab824..d72a516 100644 --- a/tests/header.t +++ b/tests/header.t @@ -1,31 +1,10 @@ -./echo "headers" +. tests/functions.sh + +title "headers" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - S=`./echo -n "$1" '..................................' | ./cols 34` - ./echo -n " $S " - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo "ok" - else - ./echo "FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'single #' '#' '

    #

    ' try 'empty ETX' '##' '

    #

    ' try 'single-char ETX (##W)' '##W' '

    W

    ' @@ -43,4 +22,5 @@ try 'SETEXT with trailing whitespace' \ 'hello ===== ' '

    hello

    ' +summary $0 exit $rc diff --git a/tests/html.t b/tests/html.t index 9f75895..f798cfc 100644 --- a/tests/html.t +++ b/tests/html.t @@ -1,29 +1,10 @@ -./echo "html blocks" +. tests/functions.sh + +title "html blocks" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'self-closing block tags (hr)' \ '
    @@ -109,4 +90,5 @@ so is this' try 'unfinished tags' '<foo bar

    ' +summary $0 exit $rc diff --git a/tests/linkylinky.t b/tests/linkylinky.t index 5761f2a..3a81db3 100644 --- a/tests/linkylinky.t +++ b/tests/linkylinky.t @@ -1,30 +1,10 @@ -./echo "embedded links" +. tests/functions.sh + +title "embedded links" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'url contains &' '[hehehe](u&rl)' '

    hehehe

    ' try 'url contains +' '[hehehe](u+rl)' '

    hehehe

    ' try 'url contains "' '[hehehe](u"rl)' '

    hehehe

    ' @@ -121,4 +101,5 @@ try '[text] (text) not a link' \ '[test] (me)' \ '

    [test] (me)

    ' +summary $0 exit $rc diff --git a/tests/linkypix.t b/tests/linkypix.t index 8ecfd41..5c7572a 100644 --- a/tests/linkypix.t +++ b/tests/linkypix.t @@ -1,29 +1,10 @@ -./echo "embedded images" +. tests/functions.sh + +title "embedded images" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'image with size extension' \ '![picture](pic =200x200)' \ '

    picture

    ' @@ -36,4 +17,5 @@ try 'image with width' \ '![picture](pic =200x)' \ '

    picture

    ' +summary $0 exit $rc diff --git a/tests/list.t b/tests/list.t index 8ffacda..a7493da 100644 --- a/tests/list.t +++ b/tests/list.t @@ -1,29 +1,9 @@ -./echo "lists" +. tests/functions.sh +title "lists" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'two separated items' \ ' * A @@ -175,4 +155,5 @@ if ./markdown -V | grep DL_TAG >/dev/null; then fi +summary $0 exit $rc diff --git a/tests/list3deep.t b/tests/list3deep.t index f28d57f..5909055 100644 --- a/tests/list3deep.t +++ b/tests/list3deep.t @@ -1,29 +1,9 @@ -./echo "deeply nested lists" +. tests/functions.sh +title "deeply nested lists" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - LIST=' * top-level list ( list 1) + second-level list (list 2) @@ -54,4 +34,5 @@ RSLT='
      try 'thrice-nested lists' "$LIST" "$RSLT" +summary $0 exit $rc diff --git a/tests/misc.t b/tests/misc.t index e437a87..6d0215c 100644 --- a/tests/misc.t +++ b/tests/misc.t @@ -1,33 +1,14 @@ -./echo "misc" +. tests/functions.sh + +title "misc" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'single paragraph' 'AAA' '

      AAA

      ' try '< -> <' '<' '

      <

      ' try '`>` -> >' '`>`' '

      >

      ' try '`` ` `` -> `' '`` ` ``' '

      `

      ' +summary $0 exit $rc diff --git a/tests/pandoc.t b/tests/pandoc.t index 9c1e7fb..4cfaf3d 100644 --- a/tests/pandoc.t +++ b/tests/pandoc.t @@ -1,31 +1,10 @@ -./echo "pandoc headers" +. tests/functions.sh + +title "pandoc headers" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - - HEADER='% title % author(s) % date' @@ -71,4 +50,5 @@ else fi +summary $0 exit $rc diff --git a/tests/para.t b/tests/para.t index d867454..29445e5 100644 --- a/tests/para.t +++ b/tests/para.t @@ -1,30 +1,10 @@ -./echo "paragraph blocking" +. tests/functions.sh + +title "paragraph blocking" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'paragraph followed by code' \ 'a b' \ @@ -35,4 +15,5 @@ try 'paragraph followed by code' \ try 'single-line paragraph' 'a' '

      a

      ' +summary $0 exit $rc diff --git a/tests/paranoia.t b/tests/paranoia.t index f2b1024..a12147b 100644 --- a/tests/paranoia.t +++ b/tests/paranoia.t @@ -1,31 +1,12 @@ -./echo "paranoia" +. tests/functions.sh + +title "paranoia" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try -fsafelink 'bogus url (-fsafelink)' '[test](bad:protocol)' '

      [test](bad:protocol)

      ' try -fnosafelink 'bogus url (-fnosafelink)' '[test](bad:protocol)' '

      test

      ' +summary $0 exit $rc diff --git a/tests/peculiarities.t b/tests/peculiarities.t index 8a199bd..3f3b63b 100644 --- a/tests/peculiarities.t +++ b/tests/peculiarities.t @@ -1,29 +1,10 @@ -./echo "markup peculiarities" +. tests/functions.sh + +title "markup peculiarities" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'list followed by header .......... ' \ " - AAA @@ -63,4 +44,5 @@ try -fnohtml 'markdown
      with -fnohtml' 'foo is' '

      foo
      is

      ' +summary $0 exit $rc diff --git a/tests/pseudo.t b/tests/pseudo.t index e2d8b76..1802554 100644 --- a/tests/pseudo.t +++ b/tests/pseudo.t @@ -1,30 +1,10 @@ -./echo "pseudo-protocols" +. tests/functions.sh + +title "pseudo-protocols" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try '[](id:) links' '[foo](id:bar)' '

      foo

      ' try -fnoext '[](id:) links with -fnoext' '[foo](id:bar)' '

      [foo](id:bar)

      ' try '[](class:) links' '[foo](class:bar)' '

      foo

      ' @@ -32,4 +12,5 @@ try -fnoext '[](class:) links with -fnoext' '[foo](class:bar)' '

      [foo](class:b try '[](raw:) links' '[foo](raw:bar)' '

      bar

      ' try -fnoext '[](raw:) links with -fnoext' '[foo](raw:bar)' '

      [foo](raw:bar)

      ' +summary $0 exit $rc diff --git a/tests/reddit.t b/tests/reddit.t index 9552885..268cbcf 100644 --- a/tests/reddit.t +++ b/tests/reddit.t @@ -1,31 +1,10 @@ -./echo "bugs & misfeatures found during the Reddit rollout" +. tests/functions.sh + +title "bugs & misfeatures found during the Reddit rollout" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - S=`./echo -n "$1" '..................................' | ./cols 34` - ./echo -n " $S " - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo "ok" - else - ./echo "FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try 'smiley faces?' '[8-9] <]:-( x ---> [4]' \ '

      [8-9] <]:–( x —–> [4]

      ' @@ -44,4 +23,5 @@ try 'unescaping " " inside []()' \ bar)' \ '

      foo

      ' +summary $0 exit $rc diff --git a/tests/reparse.t b/tests/reparse.t index b6bebd8..93e11b5 100644 --- a/tests/reparse.t +++ b/tests/reparse.t @@ -1,34 +1,14 @@ -./echo "footnotes inside reparse sections" +. tests/functions.sh + +title "footnotes inside reparse sections" rc=0 -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - - try 'footnote inside [] section' \ '[![foo][]](bar) [foo]: bar2' \ '

      foo

      ' +summary $0 exit $rc diff --git a/tests/schiraldi.t b/tests/schiraldi.t index 2d90813..3af2f68 100644 --- a/tests/schiraldi.t +++ b/tests/schiraldi.t @@ -1,31 +1,10 @@ -./echo "Bugs & misfeatures reported by Mike Schiraldi" +. tests/functions.sh + +title "Bugs & misfeatures reported by Mike Schiraldi" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - S=`./echo -n "$1" '..................................' | ./cols 34` - ./echo -n " $S " - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo "ok" - else - ./echo "FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try -fnohtml 'breaks with -fnohtml' 'foo bar' '

      foo
      bar

      ' @@ -101,4 +80,5 @@ try -fautolink 'security hole with \" in []()' \ '

      XSS

      ' +summary $0 exit $rc diff --git a/tests/smarty.t b/tests/smarty.t index e3e6e34..eefa475 100644 --- a/tests/smarty.t +++ b/tests/smarty.t @@ -1,31 +1,10 @@ -./echo "smarty pants" +. tests/functions.sh + +title "smarty pants" rc=0 MARKDOWN_FLAGS=0x0; export MARKDOWN_FLAGS -try() { - unset FLAGS - case "$1" in - -*) FLAGS="$1" - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - - try '(c) -> ©' '(c)' '

      ©

      ' try '(r) -> ®' '(r)' '

      ®

      ' try '(tm) -> ™' '(tm)' '

      ™

      ' @@ -47,4 +26,5 @@ if ./markdown -V | grep SUPERSCRIPT >/dev/null; then try -frelax 'A^B in link title' '[link](here "A^B")' '

      link

      ' fi +summary $0 exit $rc diff --git a/tests/snakepit.t b/tests/snakepit.t index 886806f..447da60 100644 --- a/tests/snakepit.t +++ b/tests/snakepit.t @@ -1,30 +1,10 @@ -./echo "The snakepit of Markdown.pl compatability" +. tests/functions.sh + +title "The snakepit of Markdown.pl compatability" rc=0 MARKDOWN_FLAGS= -try() { - unset FLAGS - case "$1" in - -*) FLAGS=$1 - shift ;; - esac - - ./echo -n " $1" '..................................' | ./cols 36 - - Q=`./echo "$2" | ./markdown $FLAGS` - - - if [ "$3" = "$Q" ]; then - ./echo " ok" - else - ./echo " FAILED" - ./echo "wanted: $3" - ./echo "got : $Q" - rc=1 - fi -} - try '[](single quote) text (quote)' \ "[foo](http://Poe's law) will make this fail ('no, it won't!') here."\ '

      foo here.

      ' @@ -42,4 +22,5 @@ try ' (2)' \ try 'paragraph
      oddity' 'EOF ' '

      EOF

      ' +summary $0 exit $rc diff --git a/tests/style.t b/tests/style.t index 5e2a735..62303c9 100644 --- a/tests/style.t +++ b/tests/style.t @@ -1,32 +1,17 @@ -./echo "styles" +. tests/functions.sh + +title "styles" rc=0 MARKDOWN_FLAGS= -./echo -n ' ' | ./markdown|wc -c` - -if [ $count -eq 1 ]; then - ./echo "ok" -else - ./echo "FAILED" - rc=1 -fi - -./echo -n ' ' '' ASK='' -count=`./echo "$ASK" | ./markdown | wc -c` - -if [ $count -eq 1 ]; then - ./echo "ok" -else - ./echo "FAILED" - rc=1 -fi +try '