about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/run.scm160
1 files changed, 103 insertions, 57 deletions
diff --git a/tests/run.scm b/tests/run.scm index 1ec4ffe..49da815 100644 --- a/tests/run.scm +++ b/tests/run.scm
@@ -1,80 +1,126 @@
1(import scheme 1(import scheme
2 (chicken base) 2 (chicken base)
3 (chicken load) 3 (chicken load)
4 (chicken pathname)
4 (chicken port) 5 (chicken port)
5 (chicken process-context) 6 (chicken process-context)
6 test) 7 test)
7 8
9(define test-dir (or (get-environment-variable "TESTS")
10 "tests"))
11
8;;; Setup 12;;; Setup
9 13
10(import (jimmy emit) 14(import (jimmy emit)
11 (jimmy read) 15 (jimmy read)
12 #;(jimmy wrap)) 16 #;(jimmy wrap))
13 17
14(define test-doc #<<end-document 18(test-begin)
15: title a test document
16: date 2024-05-13T03:02:45Z
17: uuid b3daebf1-440b-4828-a4d9-9089c7bd7c61
18
19# a test document of some kind
20 19
21here is a test document. 20;;; Reading
22it has paragraphs
23=> example.com with links!
24and other things.
25 21
26## a code example 22(define test-file (make-pathname (list test-dir) "test" "gmi"))
27``` 23(define expected-doc
28for (a=1;a<=4;a++) { 24 '((meta ("title" "a" "test" "document")
29 printf("%d\n", a); 25 ("date" "2024-05-13T03:02:45Z")
30} 26 ("uuid" "b3daebf1-440b-4828-a4d9-9089c7bd7c61"))
31``` 27 (hdr1 ("a" "test" "document" "of" "some" "kind"))
28 (para ("here" "is" "a" "test" "document.")
29 ("it" "has" "paragraphs")
30 (link "example.com" "with" "links!")
31 ("and" "other" "things."))
32 (hdr2 ("a" "code" "example"))
33 (verb ("for (a=1;a<=4;a++) {") ("\tprintf(\"%d\\n\", a);") ("}"))
34 (hdr3 ("other" "examples"))
35 (quot ("a" "blockquote" "is" "a" "quote") ("that" "is" "blocky."))
36 (list ("list" "1") ("list" "2") ("list" "3"))
37 (link ("example.com" "link" "list" "1")
38 ("example.com" "link" "list" "2")
39 ("example.com" "link" "list" "3"))
40 (para ("ok," "now" "for" "another" "test:")
41 ("will" "*strong*" "in-line" "text" "be" "converted?")
42 ("as" "well" "as" "`code`," "_emph_" "and" "such?")
43 ("what" "if" "*i" "_nest_" "them*")
44 ("what" "if" "*i" "_nest" "them*" "wrong_" "?")
45 ("what" "about" "*breaking" "them")
46 ("over" "two" "lines?*"))))
47(define actual-doc (with-input-from-file test-file parse))
32 48
33### other examples 49(test "read" expected-doc actual-doc)
34 50
35> a blockquote is a quote 51(define doc expected-doc)
36> that is blocky.
37 52
38* list 1 53;;; Emitting
39* list 2
40* list 3
41=> example.com link list 1
42=> example.com link list 2
43=> example.com link list 3
44 54
45ok, now for another test: 55(test-group "gemini"
46will *strong* in-line text be converted? 56 (define expected-gmi
47as well as `code`, _emph_ and such? 57 (string-append "# a test document of some kind\n\n"
48what if *i _nest_ them* 58 "here is a test document. it has paragraphs \n"
49what if *i _nest them* wrong_ ? 59 "=> example.com with links!\n"
50what about *breaking them 60 "and other things.\n\n"
51over two lines?* 61 "## a code example\n\n"
52end-document 62 "```\nfor (a=1;a<=4;a++) {\n"
53) 63 "\tprintf(\"%d\\n\", a);"
64 "\n}\n```\n\n"
65 "### other examples\n\n"
66 "> a blockquote is a quote that is blocky.\n\n"
67 "* list 1\n"
68 "* list 2\n"
69 "* list 3\n\n"
70 "=> example.com link list 1\n"
71 "=> example.com link list 2\n"
72 "=> example.com link list 3\n\n"
73 "ok, now for another test: "
74 "will *strong* in-line text be converted? "
75 "as well as `code`, _emph_ and such? "
76 "what if *i _nest_ them* what if *i _nest them* wrong_ ? "
77 "what about *breaking them over two lines?*\n\n"))
78 (define actual-gmi (with-output-to-string (lambda () (emit doc))))
79 (test "emit" expected-gmi actual-gmi))
54 80
55;;; Tests 81;;; HTML
56 82
57(test "read" 83(test-group "html"
58 '((meta ("title" "a" "test" "document") 84 (import (jimmy html))
59 ("date" "2024-05-13T03:02:45Z") 85 (define expected-html
60 ("uuid" "b3daebf1-440b-4828-a4d9-9089c7bd7c61")) 86 (string-append "<h1>a test document of some kind</h1>\n"
61 (hdr1 ("a" "test" "document" "of" "some" "kind")) 87 "<p>\n"
62 (para "here is a test document." "it has paragraphs" (link "example.com" 88 " here is a test document.\n"
63 "with" 89 " it has paragraphs\n"
64 "links!") 90 " <a href=\"example.com\">with links!</a>\n"
65 "and other things.") 91 " and other things.\n"
66 (hdr2 ("a" "code" "example")) 92 "</p>\n"
67 (verb "for (a=1;a<=4;a++) {" "\tprintf(\"%d\\n\", a);" "}") 93 "<h2>a code example</h2>\n"
68 (hdr3 ("other" "examples")) 94 "<pre><code>for (a=1;a<=4;a++) {\n"
69 (quot ("a" "blockquote" "is" "a" "quote") ("that" "is" "blocky.")) 95 "\tprintf(\"%d\\n\", a);\n"
70 (list ("list" "1") ("list" "2") ("list" "3")) 96 "}\n"
71 (link ("example.com" "link" "list" "1") ("example.com" "link" "list" 97 "</code></pre>\n"
72 "2") ("example.com" "link" 98 "<h3>other examples</h3>\n"
73 "list" "3")) 99 "<blockquote>\n"
74 (para "ok, now for another test:" "will *strong* in-line text be 100 " a blockquote is a quote\n"
75converted?" "as well as `code`, _emph_ and such?" "what if *i _nest_ them*" 101 " that is blocky.\n"
76"what if *i _nest them* wrong_ ?" "what about *breaking them" "over two 102 "</blockquote>\n"
77lines?*")) 103 "<ul>\n"
78 (call-with-input-string test-doc parse)) 104 " <li>list 1</li>\n"
105 " <li>list 2</li>\n"
106 " <li>list 3</li>\n"
107 "</ul>\n"
108 "<ul>\n"
109 " <li><a href=\"example.com\">link list 1</a></li>\n"
110 " <li><a href=\"example.com\">link list 2</a></li>\n"
111 " <li><a href=\"example.com\">link list 3</a></li>\n"
112 "</ul>\n"
113 "<p>\n"
114 " ok, now for another test:\n"
115 " will <b>strong</b> in-line text be converted?\n"
116 " as well as <code>code</code>, <i>emph</i> and such?\n"
117 " what if <b>i <i>nest</i> them</b>\n"
118 " what if <b>i <i>nest them</b> wrong</i> ?\n"
119 " what about *breaking them\n"
120 " over two lines?*\n"
121 "</p>\n"))
122 (define actual-html (with-output-to-string (lambda () (emit doc))))
123 (test "emit html" expected-html actual-html))
79 124
125(test-end)
80(test-exit) 126(test-exit)