aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-01-26 21:28:41 -0500
committerGravatar Peter McGoron 2025-01-26 21:28:41 -0500
commite8a6901bbc35d622e47c4927cf80e1f7a70f3ee7 (patch)
tree53807268b4e57487870b42eca0ff02abc65cf047 /tests
parentremove unordered list containers (diff)
parsing tests
Diffstat (limited to 'tests')
-rw-r--r--tests/run.scm143
1 files changed, 143 insertions, 0 deletions
diff --git a/tests/run.scm b/tests/run.scm
new file mode 100644
index 0000000..ef1c172
--- /dev/null
+++ b/tests/run.scm
@@ -0,0 +1,143 @@
+#| Copyright 2024 Peter McGoron
+ |
+ | Licensed under the Apache License, Version 2.0 (the "License");
+ |
+ | you may not use this file except in compliance with the License.
+ | You may obtain a copy of the License at
+ |
+ | http://www.apache.org/licenses/LICENSE-2.0
+ |
+ | Unless required by applicable law or agreed to in writing, software
+ | distributed under the License is distributed on an "AS IS" BASIS,
+ | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ | See the License for the specific language governing permissions and
+ | limitations under the License.
+ |#
+
+(load "../mcgoron/srfi/61.sld")
+(load "../market/string.sld")
+(load "../market/blocks.sld")
+(load "../market/default.sld")
+
+(import (prefix (only (mcgoron srfi 64) factory)
+ mcgoron-test-)
+ (srfi 64) (srfi 197) (srfi 117))
+(import (market default) (market string) (market blocks))
+
+(test-runner-factory mcgoron-test-factory)
+(test-runner-current (test-runner-create))
+
+(test-group "paragraphs"
+ (let ((str
+ (chain (parse->document "hello, world" #f)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _))))
+ (test-equal "single line" str "hello, world\n"))
+ (let ((str
+ (chain (parse->document "hello," #f)
+ (parse->document "world" _)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _))))
+ (test-equal "two lines" str "hello,\nworld\n"))
+ (test-group "two paragraphs"
+ (let ((children
+ (chain (parse->document "hello" #f)
+ (parse->document "" _)
+ (parse->document "world" _)
+ (node-children _)
+ (list-queue-list _))))
+ (test-equal "first paragraph"
+ (xstring->string (list-ref children 0))
+ "hello\n")
+ (test-equal "second paragraph"
+ (xstring->string (list-ref children 1))
+ "world\n"))))
+
+(test-group "block quotes"
+ (test-group "single line"
+ (let ((block (chain (parse->document "> hello, world" #f)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0))))
+ (test-assert "block-quote?" (block-quote? block))
+ (let ((str (chain (node-children block)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _))))
+ (test-equal "string" str "hello, world\n"))))
+ (let ((str (chain (parse->document "> hello," #f)
+ (parse->document "> world" _)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _))))
+ (test-equal "two lines" str "hello,\nworld\n"))
+ (test-group "multiple paragraphs"
+ (let ((lst (chain (parse->document "> hello" #f)
+ (parse->document "> " _)
+ (parse->document "> world" _)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (node-children _)
+ (list-queue-list _))))
+ (test-equal "first paragraph"
+ (xstring->string (list-ref lst 0))
+ "hello\n")
+ (test-equal "second paragraph"
+ (xstring->string (list-ref lst 1))
+ "world\n")))
+ (test-group "interrupted"
+ (let ((lst (chain (parse->document "> hello, world" #f)
+ (parse->document "outside of a block quote" _)
+ (node-children _)
+ (list-queue-list _))))
+ (test-assert "first is block quote"
+ (block-node? (list-ref lst 0)))
+ (let ((quote-paragraph (chain (list-ref lst 0)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _))))
+ (test-equal "block quote paragraph"
+ "hello, world\n"
+ quote-paragraph))
+ (test-assert "second is paragraph"
+ (xstring? (list-ref lst 1)))
+ (test-equal "second paragraph"
+ "outside of a block quote\n"
+ (xstring->string (list-ref lst 1)))))
+ (test-group "two nested with spaces"
+ (define block
+ (chain (parse->document "> > hello, world" #f)
+ (parse->document "> > continuing nested" _)
+ (parse->document "> outside of the block quote" _)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)))
+ (test-assert "first block quote"
+ (block-quote? block))
+ (test-equal "first block quote second paragraph"
+ "outside of the block quote\n"
+ (chain (node-children block)
+ (list-queue-list _)
+ (list-ref _ 1)
+ (xstring->string _)))
+ (set! block
+ (chain (node-children block)
+ (list-queue-list _)
+ (list-ref _ 0)))
+ (test-assert "second block quote" (block-quote? block))
+ (test-equal "second block quote paragraph"
+ "hello, world\ncontinuing nested\n"
+ (chain (node-children block)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _)))))
6-8/+106 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@37 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-09-01Added missing prototypes for iso send functions.Gravatar aeb 1-0/+7 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@36 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-08-08Added raw1394_get_irm_id().Gravatar aeb 7-7/+39 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@35 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-08-06Added support for isochronous sending.Gravatar aeb 3-0/+35 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@34 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-07-05Added raw1394_reset_bus() call.Gravatar aeb 4-0/+23 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@33 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-22- Set library version info in configure.in, use in src/Makefile.am.Gravatar aeb 4-2/+16 - Enable compiler warnings. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@32 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-15Update libtool version number.Gravatar aeb 2-2/+2 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@31 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-14Added copyright headers.Gravatar aeb 6-0/+54 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@30 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-11Added explicit AC_PROG_INSTALL call.Gravatar aeb 1-0/+1 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@29 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-09Fix size of error field.Gravatar aeb 1-2/+2 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@28 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-02Modified support for 32/64 bit environments, control struct fields have ↵Gravatar aeb 7-43/+28 fixed size now. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@27 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-05-28Added support for environments with 64 bit kernel and 32 bit userland.Gravatar aeb 8-7/+45 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@26 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-27Fixed missing setting of ext code in raw1394_start_lock()Gravatar aeb 1-0/+1 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@25 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-15Fixed lock transaction to actually return response value.Gravatar aeb 3-5/+11 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@24 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-12Add userdata functions as news.Gravatar aeb 1-0/+4 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@23 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-05Add userdata functions.Gravatar aeb 3-0/+18 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@22 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-03-18Bump version number to 0.6.Gravatar aeb 3-5/+6 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@21 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-03-18Mention byte order change.Gravatar aeb 1-0/+2 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@20 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-03-18Mention SourceForge home.Gravatar aeb 1-1/+5 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@19 53a565d1-3bb7-0310-b661-cf11e63c67ab