r7061: initial property settings
[lml2.git] / tests.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          tests.lisp
6 ;;;; Purpose:       tests file
7 ;;;; Author:        Kevin M. Rosenberg
8 ;;;; Date Started:  Apr 2003
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of LML2, is Copyright (c) 2000-2003 by Kevin Rosenberg.
13 ;;;; Rights of modification and redistribution are in the LICENSE file.
14 ;;;;
15 ;;;; *************************************************************************
16
17 (in-package #:cl)
18 (defpackage #:lml-tests
19   (:use #:lml2 #:cl #:rtest))
20 (in-package #:lml-tests)
21
22 (rem-all-tests)
23
24 (deftest lml.0
25   (with-output-to-string (s)
26     (let ((*html-stream* s))
27       (html (:div))))
28   "<div></div>")
29
30 (deftest lml.1
31   (with-output-to-string (s)
32     (let ((*html-stream* s))
33       (html ((:span class 'foo) "Foo Bar"))))
34   "<span class=\"foo\">Foo Bar</span>")
35
36 (deftest lml.2
37   (with-output-to-string (s)
38     (let ((*html-stream* s))
39       (html ((:table class "foo" :style "width:80%")
40              "Foo" " Bar" " test"))))
41   "<table class=\"foo\" style=\"width:80%\">Foo Bar test</table>")
42
43 (deftest lml.3
44   (with-output-to-string (s)
45     (let ((*html-stream* s)
46           (a 5.5d0))
47       (html (:p (:princ a)))))
48   "<p>5.5d0</p>")
49
50 (deftest lml.4
51   (with-output-to-string (s)
52     (let ((*html-stream* s)
53           (a 0.75))
54       (html ((:img :src "http://localhost/test.png" :width a)))))
55   "<img src=\"http://localhost/test.png\" width=\"0.75\" />")
56
57 (deftest lml.5
58   (with-output-to-string (s)
59     (let ((*html-stream* s))
60       (html
61        (:div "Start"
62              (:p "Testing")))))
63   "<div>Start<p>Testing</p></div>")
64
65 (deftest lml.6
66   (with-output-to-string (s)
67     (let ((*html-stream* s))
68       (html
69        ((:div :style "font-weight:bold")
70         "Start"
71         ((:p class 'a_class) "Testing")))))
72   "<div style=\"font-weight:bold\">Start<p class=\"a_class\">Testing</p></div>")
73
74 (deftest lml.7
75   (with-output-to-string (s)
76     (let ((*html-stream* s)
77           (class "aclass"))
78       (html
79        ((:div :optional (:class class))
80         "bod"))))
81   "<div class=\"aclass\">bod</div>")
82
83 (deftest lml.8
84   (with-output-to-string (s)
85     (let ((*html-stream* s)
86           (class nil))
87       (html
88        ((:div :optional (:class class))
89         "bod"))))
90   "<div>bod</div>")
91
92 (deftest lml.9
93   (with-output-to-string (s)
94     (let ((*html-stream* s)
95           (do-class t)
96           (class "aclass"))
97       (html
98        ((:div :when (:class do-class class))
99         "bod"))))
100   "<div class=\"aclass\">bod</div>")
101
102 (deftest lml.10
103   (with-output-to-string (s)
104     (let ((*html-stream* s)
105           (do-class nil)
106           (class "aclass"))
107       (html
108        ((:div :when (:class do-class class))
109         "bod"))))
110   "<div>bod</div>")
111
112
113 (deftest lml.11
114   (with-output-to-string (s)
115     (let ((*html-stream* s)
116           (v 10))
117       (html
118        ((:div :fformat (:onclick "a&b('~A')" v))))))
119   "<div onclick=\"a&b('10')\"></div>")
120
121 (deftest lml.12
122   (with-output-to-string (s)
123     (let ((*html-stream* s)
124           (v 10))
125       (html
126        ((:div :format (:onclick "a&b('~A')" v))))))
127   "<div onclick=\"a&amp;b('10')\"></div>")
128
129 (deftest lml.13
130   (with-output-to-string (s)
131     (let ((*html-stream* s)
132           (selector t)
133           (v 10))
134       (html
135        ((:div :if (:width selector 1 2))))))
136   "<div width=\"1\"></div>")
137
138 (deftest lml.14
139   (with-output-to-string (s)
140     (let ((*html-stream* s)
141           (selector nil)
142           (v 10))
143       (html
144        ((:div :if (:width selector 1 2))))))
145   "<div width=\"2\"></div>")