aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-01-30 17:24:34 -0500
committerGravatar Peter McGoron 2025-01-30 17:24:34 -0500
commit5f935e126050f6b6b59da5080a63aa1091caa6ed (patch)
treec42504542bf270df484cc7dad8a2caee97ace907
parentuse pipeline operators to write more comprehensive tests (diff)
testing unordered list items
-rw-r--r--tests/run.scm192
1 files changed, 165 insertions, 27 deletions
diff --git a/tests/run.scm b/tests/run.scm
index 87ece52..014522e 100644
--- a/tests/run.scm
+++ b/tests/run.scm
@@ -274,7 +274,7 @@
(chain-lambda (test-child "first level xstring?" xstring? 1 _)
(xstring->string _)
(test-equal-then "first level block quote text"
- "at first level\n continuing first level\n"
+ "at first level\ncontinuing first level\n"
_)))))
(test-group "atx headings"
@@ -374,7 +374,7 @@
(test-node-list "block children" 1 _)
(test-child "xstring?" xstring? 0 _)
(xstring->string _)
- (test-equal-then "text" "(procedure? call/cc)" _)))
+ (test-equal-then "text" "(procedure? call/cc)\n" _)))
(test/string "single line, 4 spaces" " ")
(test/string "single line, tab" "\t")
(with-test-chain "multiple lines, mixing"
@@ -385,7 +385,7 @@
(test-node-list "block children" 1 _)
(test-child "xstring?" xstring? 0 _)
(xstring->string _)
- (test-equal-then "text" "(lambda (x)\n x)" _))
+ (test-equal-then "text" "(lambda (x)\n x)\n" _))
(with-test-chain "no quotes in code blocks"
(test-parse->document " > not a block")
(test-node-list "document children" 1 _)
@@ -393,7 +393,7 @@
(test-node-list "block children" 1 _)
(test-child "xstring?" xstring? 0 _)
(xstring->string _)
- (test-equal-then "text" " > not a block" _))
+ (test-equal-then "text" "> not a block\n" _))
(with-test-chain "code block in quotes"
(test-parse->document "> quoted code")
(test-node-list "document children" 1 _)
@@ -405,26 +405,164 @@
(xstring->string _)
(test-equal-then "text" "quoted code\n" _)))
-#;(test-group "unordered lists"
- (test-group "one element"
- (let ((lst (chain (parse->document "* hello, world")
- (node-children _)
- (list-queue-list _)
- (list-ref _ 0))))
- (test-assert "unordered-list-item?" (unordered-list-item? lst))
- (let ((str (chain (node-children lst)
- (list-queue-list _)
- (list-ref _ 0)
- (xstring->string _))))
- (test-equal "text" "hello, world\n" str))))
- (test-group "one element continued"
- (let ((str (chain (parse->document "* hello,")
- (parse->document " world" _)
- (node-children _)
- (list-queue-list _)
- (list-ref _ 0)
- (node-children _)
- (list-queue-list _)
- (list-ref _ 0)
- (xstring->string _))))
- (test-equal "text" "hello,\nworld\n" str))))
+(test-group "unordered lists"
+ (with-test-chain "one element"
+ (test-parse->document "* hello, world")
+ (test-node-list "document children" 1 _)
+ (test-child "unordered-list-item?" unordered-list-item? 0 _)
+ (test-node-list "list children" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal "text" "hello, world\n" _))
+ (with-test-chain "one element continued"
+ (test-parse->document "* hello,")
+ (test-parse->document " world" _)
+ (test-node-list "document children" 1 _)
+ (test-child "list item" unordered-list-item? 0 _)
+ (test-node-list "list children" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal "text" "hello,\nworld\n" _))
+ (with-test-chain "one element with indentation"
+ (test-parse->document "* hello, world")
+ (test-parse->document " " _)
+ (test-parse->document " second paragraph" _)
+ (test-node-list "document children" 1 _)
+ (test-child "list item" unordered-list-item? 0 _)
+ (test-node-list "list children" 2 _)
+ (fork
+ "first paragraph"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text"
+ "hello, world\n"
+ _)))
+ (fork
+ "second paragraph"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 1 _)
+ (xstring->string _)
+ (test-equal-then "text"
+ "second paragraph\n"
+ _))))
+ (with-test-chain "one element w/o indentation"
+ (test-parse->document "* hello, world")
+ (test-parse->document "" _)
+ (test-parse->document " second paragraph" _)
+ (test-node-list "document children" 1 _)
+ (test-child "list item" unordered-list-item? 0 _)
+ (test-node-list "list children" 2 _)
+ (fork
+ "first paragraph"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text"
+ "hello, world\n"
+ _)))
+ (fork
+ "second paragraph"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 1 _)
+ (xstring->string _)
+ (test-equal-then "text"
+ "second paragraph\n"
+ _))))
+ (with-test-chain "one element interrupted"
+ (test-parse->document "* hello,")
+ (test-parse->document "world" _)
+ (test-node-list "document children" 2 _)
+ (fork
+ "list item"
+ _
+ (chain-lambda (test-child "list item" unordered-list-item? 0 _)
+ (test-node-list "items" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text" "hello,\n" _)))
+ (fork
+ "paragraph"
+ _
+ (chain-lambda (test-child "xstring" xstring? 1 _)
+ (xstring->string _)
+ (test-equal-then "text" "world\n" _))))
+ (with-test-chain "one element interrupted with empty line"
+ (test-parse->document "* hello,")
+ (test-parse->document "" _)
+ (test-parse->document "world" _)
+ (test-node-list "document children" 2 _)
+ (fork
+ "list item"
+ _
+ (chain-lambda (test-child "list item" unordered-list-item? 0 _)
+ (test-node-list "items" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text" "hello,\n" _)))
+ (fork
+ "paragraph"
+ _
+ (chain-lambda (test-child "xstring" xstring? 1 _)
+ (xstring->string _)
+ (test-equal-then "text" "world\n" _))))
+ (with-test-chain "multiple list elements"
+ (test-parse->document "* h")
+ (test-parse->document " el" _)
+ (test-parse->document "* lo" _)
+ (test-node-list "document children" 2 _)
+ (fork
+ "first list item"
+ _
+ (chain-lambda (test-child "list item" unordered-list-item? 0 _)
+ (test-node-list "items" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text" "h\nel\n" _)))
+ (fork
+ "second list item"
+ _
+ (chain-lambda (test-child "list item" unordered-list-item? 1 _)
+ (test-node-list "items" 1 _)
+ (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text" "lo\n" _))))
+ (with-test-chain "nested list elements"
+ (test-parse->document "* hello")
+ (test-parse->document " * world" _)
+ (test-parse->document "" _)
+ (test-parse->document " " _)
+ (test-parse->document " foo" _)
+ (test-parse->document " bar" _)
+ (test-node-list "document children" 1 _)
+ (test-child "list item" unordered-list-item? 0 _)
+ (test-node-list "main item children" 3 _)
+ (fork
+ "first paragraph"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text" "hello\n" _)))
+ (fork
+ "nested list item"
+ _
+ (chain-lambda (test-child "list item" unordered-list-item? 1 _)
+ (test-node-list "children" 2 _)
+ (fork
+ "first paragraph"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 0 _)
+ (xstring->string _)
+ (test-equal-then "text" "world\n" _)))
+ (fork
+ "second paragraph"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 1 _)
+ (xstring->string _)
+ (test-equal-then "text" "foo\n" _)))))
+ (fork
+ "paragraph"
+ _
+ (chain-lambda (test-child "xstring?" xstring? 2 _)
+ (xstring->string _)
+ (test-equal-then "text" "bar\n" _)))))