cmark

My personal build of CMark ✏️

Commit
cb27409921300ad5ea6ccc5e29d3c78d2ed048b3
Parent
ed990f56553f4c144c57cdff85aaa1c437ba8be2
Author
John MacFarlane <jgm@berkeley.edu>
Date

Refactored pathological_tests.py

Diffstat

1 file changed, 14 insertions, 10 deletions

Status File Name N° Changes Insertions Deletions
Modified test/pathological_tests.py 24 14 10
diff --git a/test/pathological_tests.py b/test/pathological_tests.py
@@ -71,28 +71,32 @@ pathological = {
     }
 
 whitespace_re = re.compile('/s+/')
-passed = 0
-errored = 0
-failed = 0
 
-print("Testing pathological cases:")
-for description in pathological:
+results = {'passed': 0, 'errored': 0, 'failed': 0}
+
+def run_pathological_test(description, results):
     (inp, regex) = pathological[description]
     [rc, actual, err] = cmark.to_html(inp)
     if rc != 0:
-        errored += 1
         print(description, '[ERRORED (return code %d)]' %rc)
         print(err)
+        results['errored'] += 1
     elif regex.search(actual):
         print(description, '[PASSED]')
-        passed += 1
+        results['passed'] += 1
     else:
         print(description, '[FAILED]')
         print(repr(actual))
-        failed += 1
+        results['failed'] += 1
+
+
+print("Testing pathological cases:")
+for description in pathological:
+    run_pathological_test(description, results)
 
-print("%d passed, %d failed, %d errored" % (passed, failed, errored))
-if (failed == 0 and errored == 0):
+print("%d passed, %d failed, %d errored" %
+          (results['passed'], results['failed'], results['errored']))
+if (results['failed'] == 0 and results['errored'] == 0):
     exit(0)
 else:
     exit(1)