-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.scm
145 lines (114 loc) · 2.09 KB
/
test.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
(import
(cyclone test)
(cyclone web temple parser)
(cyclone web temple)
(scheme base) )
(define view-1
"<html>
<head><title>Test View></title></head>
<body>
{
{
<p>
<a href=\"view-1.html\">
View 1
</a>
</p>
<p>
<a href=\"view-2.html\">
View 2
</a>
</p>
<p>
<a href=\"view-3.html\">
View 3
</a>
</p>
</body>
</html>
")
(define view-2
"<html>
<head><title>Test View></title></head>
<body>
some body text here...
</body>
</html>
")
(define view-3
"
<html>
<head><title>Test of a template comment></title></head>
<body>
01234
more text
</body>
</html>
")
(define view-4
"
<html>
<head><title>Test View></title></head>
<body>
<p>
<a href=\"view-2.html\">
View 2
</a>
</p>
</body>
</html>
")
(define-syntax test/output
(syntax-rules ()
((_ desc expected body ...)
(_test/output
desc
expected
(lambda ()
body ...)))))
(define (_test/output desc expected thunk)
(call-with-port
(open-output-string)
(lambda (p)
(parameterize ((current-output-port p))
(thunk)
(test
desc
expected
(get-output-string p))))))
(test-group "View snippets"
(test/output "Basic inline comment"
" test "
(render (open-input-string " test ") '()))
)
(test-group "Views from file"
(test/output
"Basic views with no embedded Scheme"
view-2
(render "examples/view-2.html" '()))
(test/output "Basic view with comments"
view-3
(render "examples/view-3.html" '()))
(test/output
"Basic view with expressions"
view-4
(render
"examples/view-4.html"
'((row . '("view-2.html" . "View 2"))
(link . car)
(desc . cdr))))
(test/output
"Basic view with statements and expressions"
view-1
(render
"examples/view-1.html"
'((rows . '(
("view-1.html" . "View 1")
("view-2.html" . "View 2")
("view-3.html" . "View 3")
))
(link . car)
(desc . cdr)))
)
)
(test-exit)