From ed4e86f47935994fb424c977e4123bde625ddff1 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 3 Jun 2024 16:56:30 -0500 Subject: Fix html/other sourcing; re-scramble Makefile --- tests/run.scm | 160 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 103 insertions(+), 57 deletions(-) (limited to 'tests') 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 @@ (import scheme (chicken base) (chicken load) + (chicken pathname) (chicken port) (chicken process-context) test) +(define test-dir (or (get-environment-variable "TESTS") + "tests")) + ;;; Setup (import (jimmy emit) (jimmy read) #;(jimmy wrap)) -(define test-doc #< example.com with links! -and other things. +;;; Reading -## a code example -``` -for (a=1;a<=4;a++) { - printf("%d\n", a); -} -``` +(define test-file (make-pathname (list test-dir) "test" "gmi")) +(define expected-doc + '((meta ("title" "a" "test" "document") + ("date" "2024-05-13T03:02:45Z") + ("uuid" "b3daebf1-440b-4828-a4d9-9089c7bd7c61")) + (hdr1 ("a" "test" "document" "of" "some" "kind")) + (para ("here" "is" "a" "test" "document.") + ("it" "has" "paragraphs") + (link "example.com" "with" "links!") + ("and" "other" "things.")) + (hdr2 ("a" "code" "example")) + (verb ("for (a=1;a<=4;a++) {") ("\tprintf(\"%d\\n\", a);") ("}")) + (hdr3 ("other" "examples")) + (quot ("a" "blockquote" "is" "a" "quote") ("that" "is" "blocky.")) + (list ("list" "1") ("list" "2") ("list" "3")) + (link ("example.com" "link" "list" "1") + ("example.com" "link" "list" "2") + ("example.com" "link" "list" "3")) + (para ("ok," "now" "for" "another" "test:") + ("will" "*strong*" "in-line" "text" "be" "converted?") + ("as" "well" "as" "`code`," "_emph_" "and" "such?") + ("what" "if" "*i" "_nest_" "them*") + ("what" "if" "*i" "_nest" "them*" "wrong_" "?") + ("what" "about" "*breaking" "them") + ("over" "two" "lines?*")))) +(define actual-doc (with-input-from-file test-file parse)) -### other examples +(test "read" expected-doc actual-doc) -> a blockquote is a quote -> that is blocky. +(define doc expected-doc) -* list 1 -* list 2 -* list 3 -=> example.com link list 1 -=> example.com link list 2 -=> example.com link list 3 +;;; Emitting -ok, now for another test: -will *strong* in-line text be converted? -as well as `code`, _emph_ and such? -what if *i _nest_ them* -what if *i _nest them* wrong_ ? -what about *breaking them -over two lines?* -end-document -) +(test-group "gemini" + (define expected-gmi + (string-append "# a test document of some kind\n\n" + "here is a test document. it has paragraphs \n" + "=> example.com with links!\n" + "and other things.\n\n" + "## a code example\n\n" + "```\nfor (a=1;a<=4;a++) {\n" + "\tprintf(\"%d\\n\", a);" + "\n}\n```\n\n" + "### other examples\n\n" + "> a blockquote is a quote that is blocky.\n\n" + "* list 1\n" + "* list 2\n" + "* list 3\n\n" + "=> example.com link list 1\n" + "=> example.com link list 2\n" + "=> example.com link list 3\n\n" + "ok, now for another test: " + "will *strong* in-line text be converted? " + "as well as `code`, _emph_ and such? " + "what if *i _nest_ them* what if *i _nest them* wrong_ ? " + "what about *breaking them over two lines?*\n\n")) + (define actual-gmi (with-output-to-string (lambda () (emit doc)))) + (test "emit" expected-gmi actual-gmi)) -;;; Tests +;;; HTML -(test "read" - '((meta ("title" "a" "test" "document") - ("date" "2024-05-13T03:02:45Z") - ("uuid" "b3daebf1-440b-4828-a4d9-9089c7bd7c61")) - (hdr1 ("a" "test" "document" "of" "some" "kind")) - (para "here is a test document." "it has paragraphs" (link "example.com" - "with" - "links!") - "and other things.") - (hdr2 ("a" "code" "example")) - (verb "for (a=1;a<=4;a++) {" "\tprintf(\"%d\\n\", a);" "}") - (hdr3 ("other" "examples")) - (quot ("a" "blockquote" "is" "a" "quote") ("that" "is" "blocky.")) - (list ("list" "1") ("list" "2") ("list" "3")) - (link ("example.com" "link" "list" "1") ("example.com" "link" "list" - "2") ("example.com" "link" - "list" "3")) - (para "ok, now for another test:" "will *strong* in-line text be -converted?" "as well as `code`, _emph_ and such?" "what if *i _nest_ them*" -"what if *i _nest them* wrong_ ?" "what about *breaking them" "over two -lines?*")) - (call-with-input-string test-doc parse)) +(test-group "html" + (import (jimmy html)) + (define expected-html + (string-append "

a test document of some kind

\n" + "

\n" + " here is a test document.\n" + " it has paragraphs\n" + " with links!\n" + " and other things.\n" + "

\n" + "

a code example

\n" + "
for (a=1;a<=4;a++) {\n"
+                   "\tprintf(\"%d\\n\", a);\n"
+                   "}\n"
+                   "
\n" + "

other examples

\n" + "
\n" + " a blockquote is a quote\n" + " that is blocky.\n" + "
\n" + "\n" + "\n" + "

\n" + " ok, now for another test:\n" + " will strong in-line text be converted?\n" + " as well as code, emph and such?\n" + " what if i nest them\n" + " what if i nest them wrong ?\n" + " what about *breaking them\n" + " over two lines?*\n" + "

\n")) + (define actual-html (with-output-to-string (lambda () (emit doc)))) + (test "emit html" expected-html actual-html)) +(test-end) (test-exit) -- cgit 1.4.1-21-gabe81