aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-01-26 22:30:53 -0500
committerGravatar Peter McGoron 2025-01-26 22:30:53 -0500
commit4b676e5bb351b3023e933148951a9fa5b5d5c80f (patch)
treef1c3d531923a2ff78c10b618b7709c9e9db9ea01 /tests
parentpartial suppor for ATX headings (diff)
indented code block test
Diffstat (limited to 'tests')
-rw-r--r--tests/run.scm68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/run.scm b/tests/run.scm
index d44abb8..550534d 100644
--- a/tests/run.scm
+++ b/tests/run.scm
@@ -250,3 +250,71 @@
(list-queue-list _)
(list-ref _ 0)
(xstring->string _)))))))
+
+(test-group "code blocks"
+ (test-group "single line, 4 spaces"
+ (let ((block (chain (parse->document " (procedure? call/cc)" #f)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0))))
+ (test-assert "code-block?" (code-block? block))
+ (test-equal "text"
+ "(procedure? call/cc)\n"
+ (chain (node-children block)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _)))))
+ (test-group "single line, tab"
+ (let ((block (chain (parse->document "\t(procedure? call/cc)" #f)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0))))
+ (test-assert "code-block?" (code-block? block))
+ (test-equal "text"
+ "(procedure? call/cc)\n"
+ (chain (node-children block)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _)))))
+ (test-group "multiple lines, mixing"
+ (let ((str (chain (parse->document " (lambda (x)" #f)
+ (parse->document "\t x)" _)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _))))
+ (test-equal "text"
+ "(lambda (x)\n x)\n"
+ str)))
+ (test-group "no quotes in code blocks"
+ (let ((first-child (chain (parse->document " > not a block" #f)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0))))
+ (test-assert "xstring" (xstring? first-child))
+ (test-equal "text"
+ "> not a block\n"
+ (xstring->string first-child))))
+ (test-group "code block in quotes"
+ (let ((node (chain (parse->document "> quoted code" #f)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0))))
+ (test-assert "block-quote?" (block-quote? node))
+ (set! node (chain (node-children node)
+ (list-queue-list _)
+ (list-ref _ 0)))
+ (test-assert "code-block?" (code-block? node))
+ (set! text (chain (node-children node)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _)))
+ (test-equal "text"
+ "quoted code\n"
+ text))))