source: project/release/4/spiffy-request-vars/trunk/tests/server.scm @ 18251

Last change on this file since 18251 was 18251, checked in by Mario Domenech Goulart, 11 years ago

spiffy-request-vars (trunk): added more tests

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/usr/bin/awful
2
3(use srfi-69 awful spiffy-request-vars spiffy intarweb uri-common html-tags)
4
5(page-template (lambda (contents . more) contents))
6
7(debug-log (current-error-port))
8
9(page-exception-message
10 (lambda (exn)
11   (<pre> convert-to-entities?: #t
12          (with-output-to-string
13            (lambda ()
14              (print-call-chain)
15              (print-error-message exn))))))
16
17(define (show var)
18  (with-output-to-string (cut write var)))
19
20(define-page "as-string" (lambda () (show ($ 'var))))
21
22(define-page "as-number" (lambda () (show ($ 'var as-number))))
23
24(define-page "as-boolean" (lambda () (show ($ 'var as-boolean))))
25
26(define-page "as-list" (lambda () (show ($ 'var as-list))))
27
28(define-page "as-vector" (lambda () (show ($ 'var as-vector))))
29
30(define-page "as-alist" (lambda () (show ($ 'var as-alist))))
31
32(define-page "as-hash-table"
33  (lambda ()
34    (and-let* ((var ($ 'var as-hash-table)))
35      (show (hash-table->alist var)))))
36
37
38;;; with-request-vars
39(define-page "wrv-as-string"
40  (lambda ()
41    (with-request-vars* $ (var)
42        (show var))))
43
44(define-page "wrv-as-number"
45  (lambda ()
46    (with-request-vars ((var as-number))
47        (show var))))
48
49(define-page "wrv-as-boolean"
50  (lambda ()
51    (with-request-vars ((var as-boolean))
52        (show var))))
53
54(define-page "wrv-as-list"
55  (lambda ()
56    (with-request-vars ((var as-list))
57        (show var))))
58
59(define-page "wrv-as-vector"
60  (lambda ()
61    (with-request-vars ((var as-vector))
62        (show var))))
63
64(define-page "wrv-as-alist"
65  (lambda ()
66    (with-request-vars ((var as-alist))
67        (show var))))
68
69(define-page "wrv-as-hash-table"
70  (lambda ()
71    (with-request-vars ((var as-hash-table))
72        (and var (show (hash-table->alist var))))))
Note: See TracBrowser for help on using the repository browser.