Changeset 18251 in project


Ignore:
Timestamp:
05/29/10 21:45:41 (11 years ago)
Author:
Mario Domenech Goulart
Message:

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

Location:
release/4/spiffy-request-vars/trunk/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/spiffy-request-vars/trunk/tests/client.scm

    r18153 r18251  
    11#!/usr/bin/csi -script
    22
    3 (use test http-client)
     3(use test http-client spiffy-request-vars)
    44
    55(define (get path/vars)
    6   (with-input-from-request
    7    (string-append "http://localhost:8080" path/vars)
    8    #f read))
     6  (let ((val (with-input-from-request
     7              (string-append "http://localhost:8080" path/vars)
     8              #f read)))
     9    (close-all-connections!)
     10    val))
     11
     12(test-begin "spiffy-request-vars")
    913
    1014;;; Strings
    1115(test #f (get "/as-string"))
     16(test #f (get "/wrv-as-string"))
    1217
    1318(test "a" (get "/as-string?var=a"))
     19(test "a" (get "/wrv-as-string?var=a"))
    1420
    1521(test "a" (get "/as-string?var=a;var=b"))
     22(test "a" (get "/wrv-as-string?var=a;var=b"))
     23
     24(test "1" (get "/as-string?var=1"))
     25(test "1" (get "/wrv-as-string?var=1"))
    1626
    1727
    1828;;; Numbers
     29(test #f (get "/as-number"))
     30(test #f (get "/wrv-as-number"))
     31
    1932(test 3 (get "/as-number?var=3"))
     33(test 3 (get "/wrv-as-number?var=3"))
    2034
    2135(test #f (get "/as-number?foo=3"))
     36(test #f (get "/wrv-as-number?foo=3"))
     37
     38(test #f (get "/as-number?var=a"))
     39(test #f (get "/wrv-as-number?var=a"))
    2240
    2341
    2442;;; Booleans
    2543(test #f (get "/as-boolean"))
     44(test #f (get "/wrv-as-boolean"))
    2645
    2746(test #t (get "/as-boolean?var=yes"))
     47(test #t (get "/wrv-as-boolean?var=yes"))
     48
     49(test #t (get "/as-boolean?var=Yes"))
     50(test #t (get "/wrv-as-boolean?var=Yes"))
     51
     52(test #t (get "/as-boolean?var=1"))
     53(test #t (get "/wrv-as-boolean?var=1"))
     54
     55(test #f (get "/as-boolean?var=0"))
     56(test #f (get "/wrv-as-boolean?var=0"))
    2857
    2958
    3059;;; List
    31 (test '("a" "b")
    32       (get "/as-list?var=a;var=b"))
     60(test #f (get "/as-list"))
     61(test #f (get "/wrv-as-list"))
    3362
    34 (test '("c")
    35       (get "/as-list?var=c"))
     63(test '("a" "b") (get "/as-list?var=a;var=b"))
     64(test '("a" "b") (get "/wrv-as-list?var=a;var=b"))
    3665
    37 (test #f
    38       (get "/as-list"))
     66(test '("a" "b") (get "/as-list?var=a;var=b;varb=4"))
     67(test '("a" "b") (get "/wrv-as-list?var=a;var=b;varb=4"))
     68
     69(test '("c") (get "/as-list?var=c"))
     70(test '("c") (get "/wrv-as-list?var=c"))
     71
    3972
    4073;;; Vectors
    41 (test '#("a" "b")
    42       (get "/as-vector?var.0=a;var.1=b"))
     74(test #f (get "/as-vector"))
     75(test #f (get "/wrv-as-vector"))
    4376
    44 (test #f
    45       (get "/as-vector?var=c"))
     77(test '#("a" "b") (get "/as-vector?var.0=a;var.1=b"))
     78(test '#("a" "b") (get "/wrv-as-vector?var.0=a;var.1=b"))
    4679
    47 (test '#("a" "b")
    48       (get "/as-vector?var.0=a;var.1=b"))
     80(test 3 (vector-length (get "/as-vector?var.0=a;var.1=b;var.2=4;varc=4")))
     81(test 3 (vector-length (get "/wrv-as-vector?var.0=a;var.1=b;var.2=4;varc=4")))
     82
     83(test #f (get "/as-vector?var=c"))
     84(test #f (get "/wrv-as-vector?var=c"))
     85
     86(test '#("a" "b") (get "/as-vector?var.0=a;var.1=b;var3=c"))
     87(test '#("a" "b") (get "/wrv-as-vector?var.0=a;var.1=b;var3=c"))
     88
    4989
    5090;;; Alists
    51 (test '((A . "a") (B . "b"))
    52       (get "/as-alist?var.A=a;var.B=b"))
     91(test #f (get "/as-list"))
     92(test #f (get "/wrv-as-alist"))
    5393
    54 (test #f
    55       (get "/as-alist?var=c"))
     94(test '((A . "a") (B . "b")) (get "/as-alist?var.A=a;var.B=b"))
     95(test '((A . "a") (B . "b")) (get "/wrv-as-alist?var.A=a;var.B=b"))
     96
     97(test #f (get "/as-alist?var=c"))
     98(test #f (get "/wrv-as-alist?var=c"))
    5699
    57100
    58101;;; Hash-tables
    59 (test '((B . "b") (A . "a"))
    60       (get "/as-hash-table?var.A=a;var.B=b"))
     102(test #f (get "/as-hash-table"))
     103(test #f (get "/wrv-as-hash-table"))
    61104
    62 (test #f
    63       (get "/as-hash-table?var=c"))
     105(test '((B . "b") (A . "a")) (get "/as-hash-table?var.A=a;var.B=b"))
     106(test '((B . "b") (A . "a")) (get "/wrv-as-hash-table?var.A=a;var.B=b"))
     107
     108(test #f (get "/as-hash-table?var=c"))
     109(test #f (get "/wrv-as-hash-table?var=c"))
     110
     111
     112(test-end "spiffy-request-vars")
  • release/4/spiffy-request-vars/trunk/tests/server.scm

    r18156 r18251  
    3434    (and-let* ((var ($ 'var as-hash-table)))
    3535      (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 TracChangeset for help on using the changeset viewer.