From b2e889fa63a927dc5de5335df232b745030b12dd Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Thu, 26 Jan 2017 19:18:00 -0500 Subject: [PATCH] ADDED: Add pathological test suite from CommonMark --- tools/pathological_tests.sh | 108 ++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100755 tools/pathological_tests.sh diff --git a/tools/pathological_tests.sh b/tools/pathological_tests.sh new file mode 100755 index 0000000..2eeecb7 --- /dev/null +++ b/tools/pathological_tests.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +X=65535 +#X=100 + +Y=$((X-1)) + +# Pathological tests from CommonMark + +# Nested strong/emph +seq -f "*a **a" $X > path1.text +echo -n "b " >> path1.text +seq -f "a** a*" $X >> path1.text + +echo -n "

" > path1.html +seq -f "a a" $X >> path1.html +echo -n "b " >> path1.html +seq -f "a a" $Y >> path1.html +echo "a a

" >> path1.html + + +# Close unopened emph +seq -f "a_" $X > path2.text + +echo -n "

" > path2.html +seq -f "a_" $Y >> path2.html +echo "a_

" >> path2.html + + +# Open unclosed emph +seq -f "_a" $X > path3.text + +echo -n "

" > path3.html +seq -f "_a" $Y >> path3.html +echo "_a

" >> path3.html + + +# Close unopened links +seq -f "a]" $X > path4.text + +echo -n "

" > path4.html +seq -f "a]" $Y >> path4.html +echo "a]

" >> path4.html + + +# Open unclosed links +seq -f "[a" $X > path5.text + +echo -n "

" > path5.html +seq -f "[a" $Y >> path5.html +echo "[a

" >> path5.html + + +# Mismatched * and _ +# TODO: Starts getting slow > 10k iterations +# Walking entire stack to find that there is no match. +# Could keep count of different token types on stack +# To ensure there's even something to find. Which does +# mean more overhead CPU time +seq -f "*a_" $X > path6.text + +echo -n "

" > path6.html +seq -f "*a_" $Y >> path6.html +echo "*a_

" >> path6.html + + +# Unclosed links and unopened emph +seq -f "[ a_" $X > path7.text + +echo -n "

" > path7.html +seq -f "[ a_" $Y >> path7.html +echo "[ a_

" >> path7.html + + +# Complex case +seq -f "**x [*b**c*](d)" $X > path8.text + +echo -n "

" > path8.html +seq -f "**x abc" $Y >> path8.html +echo "**x abc

" >> path8.html + + +# Nested brackets +# TODO: Performance hit between 1000 and 10,000 iterations +# Checking each level to see if it's a valid link on the stack +seq -s " " -f "[" $X > path9.text +echo -n "a" >> path9.text +seq -s " " -f "]" $X >> path9.text + +echo -n "

" > path9.html +seq -s " " -f "[" $X >> path9.html +echo -n "a" >> path9.html +seq -s " " -f "]" $Y >> path9.html +echo "]

" >> path9.html + + +# Nested block quotes +# TODO: Segfaults -- recursive parsing after ~~10k nests +seq -s " " -f ">" $X > path10.text +echo -n "a" >> path10.text + +echo -n "

" > path10.html +seq -f "

" $X >> path10.html +echo -n "a" >> path10.html +seq -f "
" $X >> path10.html +echo -n "

" >> path10.html + + -- 2.40.0