aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-02-01 23:12:50 -0500
committerGravatar Peter McGoron 2025-02-01 23:12:50 -0500
commit2fd29bc60be4f72f27466cc5394e6309bac672c7 (patch)
tree9bbd4c901ea7e39327ea189c42621772989b191f /tests
parenttesting unordered list items (diff)
thematic breaks
Diffstat (limited to 'tests')
-rw-r--r--tests/run.scm104
1 files changed, 104 insertions, 0 deletions
diff --git a/tests/run.scm b/tests/run.scm
index 014522e..2fef24a 100644
--- a/tests/run.scm
+++ b/tests/run.scm
@@ -566,3 +566,107 @@
(chain-lambda (test-child "xstring?" xstring? 2 _)
(xstring->string _)
(test-equal-then "text" "bar\n" _)))))
+
+(test-group "thematic breaks"
+ (define (test-single-thematic-break name data)
+ (with-test-chain name
+ (test-parse->document data)
+ (test-node-list "document children" 1 _)
+ (test-child "thematic break" thematic-break? 0 _)))
+ (define (test-as-code-block name data)
+ (with-test-chain name
+ (test-parse->document (string-append "\t" data))
+ (test-node-list "document-children" 1 _)
+ (test-child "code block" code-block? 0 _)
+ (test-node-list "block list" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text"
+ (string-append data "\n")
+ _)))
+ (define (test-as-paragraph name data)
+ (with-test-chain name
+ (test-parse->document data)
+ (test-node-list "document children" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text"
+ (string-append data "\n")
+ _)))
+ (test-single-thematic-break "***" "***")
+ (test-single-thematic-break " ***" " ***")
+ (test-single-thematic-break " ***" " ***")
+ (test-single-thematic-break " ***" " ***")
+ (test-single-thematic-break "* * *" "* * *")
+ (test-single-thematic-break "*********" "*********")
+ (test-as-code-block "code block ***" "***")
+ (test-as-paragraph "**" "**")
+ (test-as-paragraph "***a***" "***a***")
+ (test-single-thematic-break "-" "---")
+ (test-single-thematic-break " -" " ---")
+ (test-single-thematic-break " -" " ---")
+ (test-single-thematic-break " -" " ---")
+ (test-as-code-block "code block ---" "---")
+ (test-as-paragraph "--" "--")
+ (test-as-paragraph "--" "--")
+ (test-as-paragraph "---a" "---a")
+ (test-as-paragraph " -----a------" " -----a------")
+ (test-single-thematic-break "- - -" "- - -")
+ (test-single-thematic-break "---------" "---------")
+ (test-single-thematic-break "_" "___")
+ (test-single-thematic-break " _" " ___")
+ (test-single-thematic-break " _" " ___")
+ (test-single-thematic-break " _" " ___")
+ (test-as-code-block "code block ___" "___")
+ (test-as-paragraph "__" "__")
+ (test-single-thematic-break "_ _ _" "_ _ _")
+ (test-single-thematic-break "_________" "_________")
+ (test-as-paragraph "__" "__")
+ (test-as-paragraph "___a" "___a")
+ (test-as-paragraph " _____a______" " _____a______")
+ (with-test-chain "break takes precedence"
+ (test-parse->document "* hello")
+ (test-parse->document "* * *" _)
+ (test-parse->document "* world" _)
+ (test-node-list "document children" 3 _)
+ (fork
+ "first list item"
+ _
+ (chain-lambda (test-child "unordered list?" unordered-list-item? 0 _)
+ (test-node-list "children" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text" "hello\n" _)))
+ (fork
+ "thematic break"
+ _
+ (chain-lambda (test-child "thematic break" thematic-break? 1 _)))
+ (fork
+ "third list item"
+ _
+ (chain-lambda (test-child "unordered list?" unordered-list-item? 2 _)
+ (test-node-list "children" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text" "world\n" _))))
+ (with-test-chain "interrupt paragraph"
+ (test-parse->document "hello")
+ (test-parse->document "***" _)
+ (test-parse->document "world" _)
+ (test-node-list "document children" 3 _)
+ (fork
+ "hello"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text" "hello\n" _)))
+ (fork
+ "break"
+ _
+ (chain-lambda (test-child "thematic break" thematic-break? 1 _)))
+ (fork
+ "world"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 2 _)
+ (xstring->string _)
+ (test-equal-then "text" "world\n" _)))))