From 8b08528f6a597a298ca1d6a20f23a8823b88db59 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 28 May 2023 13:28:19 -0700 Subject: Starting TL-WHO tests. * test/simple: renamed to simple.tl. Just a self-contained file we can run. The first test has been rewritten to TL. After that we (exit). The first test is failing; it is not rendering any attributes. --- test/simple | 294 ------------------------------------------------------ test/simple.tl | 306 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 306 insertions(+), 294 deletions(-) delete mode 100644 test/simple create mode 100644 test/simple.tl diff --git a/test/simple b/test/simple deleted file mode 100644 index c952fa0..0000000 --- a/test/simple +++ /dev/null @@ -1,294 +0,0 @@ -;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-WHO-TEST; Base: 10 -*- -;;; $Header: /usr/local/cvsrep/cl-who/test/simple,v 1.4 2009/01/26 11:10:52 edi Exp $ - -;;; some simple tests for CL-WHO - entered manually and to be read -;;; in the CL-WHO-TEST package; all forms are expected to return a -;;; true value on success when EVALuated - -;;; 1 -(string= (with-output-to-string (out) - (with-html-output (out) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br)))) - "Frank Zappa
Marcus Miller
Miles Davis
") - -;;; 2 -(string= (with-output-to-string (out) - (with-html-output (out nil) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br)))) - "Frank Zappa
Marcus Miller
Miles Davis
") - -;;; 3 -(string= (with-output-to-string (foo) - (with-html-output (out foo) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br)))) - "Frank Zappa
Marcus Miller
Miles Davis
") - -;;; 4 -(string= (with-html-output-to-string (out) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br))) - "Frank Zappa
Marcus Miller
Miles Davis
") - -;;; 5 -(string= (with-html-output-to-string (out nil) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br))) - "Frank Zappa
Marcus Miller
Miles Davis
") - -;;; 6 -(string= (with-html-output-to-string (out nil :prologue nil) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br))) - "Frank Zappa
Marcus Miller
Miles Davis
") - -;;; 7 -(eq (array-element-type - (with-html-output-to-string (out nil :element-type 'base-char) - (:br))) - 'base-char) - -;;; 8 -(string= (let ((*attribute-quote-char* #\")) - (with-html-output-to-string (out) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br)))) - "Frank Zappa
Marcus Miller
Miles Davis
") - -;;; 9 -(string= (with-html-output-to-string (out nil :prologue t) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br))) - " -Frank Zappa
Marcus Miller
Miles Davis
") - -;;; 10 -(string= (with-html-output-to-string - (out nil :prologue "") - (:apply (:factorial) (:cn "3"))) - " -3") - -;;; 11 -(string= (let ((*prologue* "")) - (eval `(with-html-output-to-string (out nil :prologue t) - (:apply (:factorial) (:cn "3"))))) - " -3") - -;;; 12 -(string= (with-html-output-to-string (out nil :indent t) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br))) - " - - Frank Zappa - - -
- - Marcus Miller - - -
- - Miles Davis - - -
") - -;;; 13 -(string= (with-html-output-to-string (out nil :indent 0) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br))) - " - - Frank Zappa - - -
- - Marcus Miller - - -
- - Miles Davis - - -
") - -;;; 14 -(string= (with-html-output-to-string (out nil :indent 3) - (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") - ("http://marcusmiller.com/" . "Marcus Miller") - ("http://www.milesdavis.com/" . "Miles Davis")) - do (htm (:a :href link - (:b (str title))) - :br))) - " - - Frank Zappa - - -
- - Marcus Miller - - -
- - Miles Davis - - -
") - -;;; 15 -(string= (with-html-output-to-string (out) - (:table :border 0 :cellpadding 4 - (loop for i below 25 by 5 - do (htm - (:tr :align "right" - (loop for j from i below (+ i 5) - do (htm - (:td :bgcolor (if (oddp j) - "pink" - "green") - (fmt "~@R" (1+ j)))))))))) - "
IIIIIIIVV
VIVIIVIIIIXX
XIXIIXIIIXIVXV
XVIXVIIXVIIIXIXXX
XXIXXIIXXIIIXXIVXXV
") - -;;; 16 -(string= (with-html-output-to-string (out) - (:h4 "Look at the character entities generated by this example") - (loop for i from 0 - for string in '("Fête" "Sørensen" "naïve" "Hühner" "Straße") - do (htm - (:p :style (conc "background-color:" (case (mod i 3) - ((0) "red") - ((1) "orange") - ((2) "blue"))) - (htm (esc string)))))) - "

Look at the character entities generated by this example

Fête

Sørensen

naïve

Hühner

Straße

") - -;;; 17 -(flet ((checkbox (stream name checked &optional value) - (with-html-output (stream) - (:input :type "checkbox" :name name :checked checked :value value)))) - (and (string= (with-output-to-string (s) (checkbox s "foo" t)) - "") - (string= (with-output-to-string (s) (checkbox s "foo" nil)) - "") - (string= (with-output-to-string (s) (checkbox s "foo" nil "bar")) - "") - (string= (with-output-to-string (s) (checkbox s "foo" t "bar")) - ""))) - -;;; 18 -(string= (with-html-output-to-string (out) - (:p)) - "

") - -;;; 19 -(string= (let ((cl-who:*html-empty-tag-aware-p* nil)) - (eval `(with-html-output-to-string (out) - (:p)))) - "

") - -;;; 20 -(string= (let ((*html-empty-tag-aware-p* t) - (*html-empty-tags* '(:p))) - (eval `(with-html-output-to-string (out) - (:p)))) - "

") - -;;; 21 -(string= (with-html-output-to-string (out) - (:|Foo| :bar 42)) - "") - -;;; 22 -(string= (let ((*downcase-tokens-p* nil)) - (eval `(with-html-output-to-string (out) - (:|Foo| :bar 42)))) - "") - -;;; 23 -(string= (let* ((list (list (make-string-output-stream) (make-string-output-stream))) - (stream (first list))) - (with-html-output (var (pop list)) - (progn (htm (:br)))) - (get-output-stream-string stream)) - "
") - -;;; 24 -(string= (with-html-output-to-string (out) - (:div (:pre "Foo"))) - "

Foo
") - -;;; 25 -(string= (with-html-output-to-string (out nil :indent t) - (:div (:pre "Foo"))) - " -
-
Foo
-
") - -;;; 26 -(string= (with-html-output-to-string (out nil :indent t) - (:div (:p "Bar"))) - " -
-

Bar -

-
") - -;;; 27 -(string= (let ((*html-no-indent-tags* (cons :p *html-no-indent-tags*))) - (eval `(with-html-output-to-string (out nil :indent t) - (:div (:p "Bar"))))) - " -
-

Bar

-
") diff --git a/test/simple.tl b/test/simple.tl new file mode 100644 index 0000000..1100f25 --- /dev/null +++ b/test/simple.tl @@ -0,0 +1,306 @@ +;;; some simple tests for TL-WHO. + +(load "../tl-who") + +(defpackage "tl-who-test" + (:fallback "tl-who" "usr")) + +(in-package "tl-who-test") + +(defmacro test (test-expr expected-expr) + (with-gensyms (te ee) + ^(let ((,te ,test-expr) + (,ee ,expected-expr)) + (unless (equal ,te ,ee) + (error "~s\nproduced:\n~s\nrather than:\n~s" + ',test-expr ,te ,ee))))) + +;;; 1 +(test (with-out-string-stream (out) + (with-html-output (out) + (keep-matches ((@link . @title) '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis"))) + (htm (:a :href link + (:b (str title))) + :br)))) + "Frank Zappa
Marcus Miller
Miles Davis
") + +(exit) + +;;; 2 +(string= (with-output-to-string (out) + (with-html-output (out nil) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br)))) + "Frank Zappa
Marcus Miller
Miles Davis
") + +;;; 3 +(string= (with-output-to-string (foo) + (with-html-output (out foo) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br)))) + "Frank Zappa
Marcus Miller
Miles Davis
") + +;;; 4 +(string= (with-html-output-to-string (out) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br))) + "Frank Zappa
Marcus Miller
Miles Davis
") + +;;; 5 +(string= (with-html-output-to-string (out nil) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br))) + "Frank Zappa
Marcus Miller
Miles Davis
") + +;;; 6 +(string= (with-html-output-to-string (out nil :prologue nil) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br))) + "Frank Zappa
Marcus Miller
Miles Davis
") + +;;; 7 +(eq (array-element-type + (with-html-output-to-string (out nil :element-type 'base-char) + (:br))) + 'base-char) + +;;; 8 +(string= (let ((*attribute-quote-char* #\")) + (with-html-output-to-string (out) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br)))) + "Frank Zappa
Marcus Miller
Miles Davis
") + +;;; 9 +(string= (with-html-output-to-string (out nil :prologue t) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br))) + " +Frank Zappa
Marcus Miller
Miles Davis
") + +;;; 10 +(string= (with-html-output-to-string + (out nil :prologue "") + (:apply (:factorial) (:cn "3"))) + " +3") + +;;; 11 +(string= (let ((*prologue* "")) + (eval `(with-html-output-to-string (out nil :prologue t) + (:apply (:factorial) (:cn "3"))))) + " +3") + +;;; 12 +(string= (with-html-output-to-string (out nil :indent t) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br))) + " + + Frank Zappa + + +
+ + Marcus Miller + + +
+ + Miles Davis + + +
") + +;;; 13 +(string= (with-html-output-to-string (out nil :indent 0) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br))) + " + + Frank Zappa + + +
+ + Marcus Miller + + +
+ + Miles Davis + + +
") + +;;; 14 +(string= (with-html-output-to-string (out nil :indent 3) + (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") + ("http://marcusmiller.com/" . "Marcus Miller") + ("http://www.milesdavis.com/" . "Miles Davis")) + do (htm (:a :href link + (:b (str title))) + :br))) + " + + Frank Zappa + + +
+ + Marcus Miller + + +
+ + Miles Davis + + +
") + +;;; 15 +(string= (with-html-output-to-string (out) + (:table :border 0 :cellpadding 4 + (loop for i below 25 by 5 + do (htm + (:tr :align "right" + (loop for j from i below (+ i 5) + do (htm + (:td :bgcolor (if (oddp j) + "pink" + "green") + (fmt "~@R" (1+ j)))))))))) + "
IIIIIIIVV
VIVIIVIIIIXX
XIXIIXIIIXIVXV
XVIXVIIXVIIIXIXXX
XXIXXIIXXIIIXXIVXXV
") + +;;; 16 +(string= (with-html-output-to-string (out) + (:h4 "Look at the character entities generated by this example") + (loop for i from 0 + for string in '("Fête" "Sørensen" "naïve" "Hühner" "Straße") + do (htm + (:p :style (conc "background-color:" (case (mod i 3) + ((0) "red") + ((1) "orange") + ((2) "blue"))) + (htm (esc string)))))) + "

Look at the character entities generated by this example

Fête

Sørensen

naïve

Hühner

Straße

") + +;;; 17 +(flet ((checkbox (stream name checked &optional value) + (with-html-output (stream) + (:input :type "checkbox" :name name :checked checked :value value)))) + (and (string= (with-output-to-string (s) (checkbox s "foo" t)) + "") + (string= (with-output-to-string (s) (checkbox s "foo" nil)) + "") + (string= (with-output-to-string (s) (checkbox s "foo" nil "bar")) + "") + (string= (with-output-to-string (s) (checkbox s "foo" t "bar")) + ""))) + +;;; 18 +(string= (with-html-output-to-string (out) + (:p)) + "

") + +;;; 19 +(string= (let ((cl-who:*html-empty-tag-aware-p* nil)) + (eval `(with-html-output-to-string (out) + (:p)))) + "

") + +;;; 20 +(string= (let ((*html-empty-tag-aware-p* t) + (*html-empty-tags* '(:p))) + (eval `(with-html-output-to-string (out) + (:p)))) + "

") + +;;; 21 +(string= (with-html-output-to-string (out) + (:|Foo| :bar 42)) + "") + +;;; 22 +(string= (let ((*downcase-tokens-p* nil)) + (eval `(with-html-output-to-string (out) + (:|Foo| :bar 42)))) + "") + +;;; 23 +(string= (let* ((list (list (make-string-output-stream) (make-string-output-stream))) + (stream (first list))) + (with-html-output (var (pop list)) + (progn (htm (:br)))) + (get-output-stream-string stream)) + "
") + +;;; 24 +(string= (with-html-output-to-string (out) + (:div (:pre "Foo"))) + "

Foo
") + +;;; 25 +(string= (with-html-output-to-string (out nil :indent t) + (:div (:pre "Foo"))) + " +
+
Foo
+
") + +;;; 26 +(string= (with-html-output-to-string (out nil :indent t) + (:div (:p "Bar"))) + " +
+

Bar +

+
") + +;;; 27 +(string= (let ((*html-no-indent-tags* (cons :p *html-no-indent-tags*))) + (eval `(with-html-output-to-string (out nil :indent t) + (:div (:p "Bar"))))) + " +
+

Bar

+
") -- cgit v1.2.3