Changeset 12651 in project


Ignore:
Timestamp:
11/29/08 16:16:10 (13 years ago)
Author:
azul
Message:

Switch to new embedded-test egg.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/svnwiki-enscript/trunk/svnwiki-enscript.scm

    r12623 r12651  
    44
    55(declare (export))
    6 (use svnwiki-extensions-support srfi-40 html-stream stream-ext embedded-unittest stream-wiki)
     6(use svnwiki-extensions-support srfi-40 html-stream stream-ext embedded-test stream-wiki)
    77
    88(define (stream-take-while-all pred str)
     
    8888    ((text html) html)))
    8989
     90(test-group enscript-type->html
     91  (test (enscript-type->mime 'sh) "application/x-sh")
     92  (test (not (enscript-type->mime 'unknown))))
     93
    9094(define (enscript-type->mime type)
    9195  (and-let* ((result (find (lambda (x) (eq? (cadr x) type))
     
    9397    (format #f "~A/~A" (caar result) (cadar result))))
    9498
    95 (unittest (enscript-type->mime 'sh) "application/x-sh")
    96 (unittest (not (enscript-type->mime 'unknown)))
     99(test-group mime->enscript-type
     100  (test (mime->enscript-type
     101          (environment ((path-in "/tmp") (path "/foo")))
     102          (lambda (type path default)
     103            (if (and (string=? path "/tmp/foo")
     104                     (string=? type "svn:mime-type"))
     105              "application/x-sh"
     106              (error "Invalid call" path type))))
     107        'sh)
     108
     109  (test (not (mime->enscript-type
     110               (environment ((path-in "/tmp") (path "/foo")))
     111               (lambda (type path default) default)))))
    97112
    98113; Optionals parameters are used for testing only.  Don't use them for any other
     
    111126                              *enscript-types*)))
    112127        (cadr data)))))
    113 
    114 (unittest (mime->enscript-type
    115             (environment ((path-in "/tmp") (path "/foo")))
    116             (lambda (type path default)
    117               (if (and (string=? path "/tmp/foo")
    118                        (string=? type "svn:mime-type"))
    119                 "application/x-sh"
    120                 (error "Invalid call" path type))))
    121           'sh)
    122 
    123 (unittest (not (mime->enscript-type
    124                  (environment ((path-in "/tmp") (path "/foo")))
    125                  (lambda (type path default) default))))
    126128
    127129(define (svnwiki-enscript-handler-render env)
     
    140142            (svnwiki-render-file-contents-tail env)))))))
    141143
     144(test-group stream-group
     145  (test (map stream->list (stream->list (stream-group (stream 1 2 3 4 5) even?)))
     146        '((1 3 5) (2 4))))
     147
    142148(define (stream-group str key-proc)
    143149  (let ((hash (make-hash-table))
     
    155161      (list->stream (reverse order)))))
    156162
    157 (unittest (map stream->list (stream->list (stream-group (stream 1 2 3 4 5) even?)))
    158           '((1 3 5) (2 4)))
    159 
    160163(define (group-chunks chunks)
    161164  (stream-group chunks (lambda (x) (list (car x) (cadr x)))))
     165
     166(test-group enscript-make-pathname
     167  (test (enscript-make-pathname "foo/bar" "~/bin/xload")
     168        "foo/xsvnwiki-enscript/bar/xload")
     169
     170  (test (enscript-make-pathname "foo/bar" "bin/../../../../../../xload")
     171        "foo/xsvnwiki-enscript/bar/xload")
     172
     173  (test (enscript-make-pathname "bar" "~/bin/xload")
     174        "xsvnwiki-enscript/bar/xload")
     175
     176  (test (enscript-make-pathname "bar" "xload.may-there")
     177        "xsvnwiki-enscript/bar/xload-may-there")
     178
     179  (test (enscript-make-pathname "bar" "xload" "application/x-scheme")
     180        "xsvnwiki-enscript/bar/xload.scm"))
    162181
    163182(define (enscript-make-pathname path subpath . rest)
     
    177196          (string->stream (svnwiki-basename subpath))))
    178197      (mime->ending mime))))
    179 
    180 (unittest (enscript-make-pathname "foo/bar" "~/bin/xload")
    181           "foo/xsvnwiki-enscript/bar/xload")
    182 
    183 (unittest (enscript-make-pathname "foo/bar" "bin/../../../../../../xload")
    184           "foo/xsvnwiki-enscript/bar/xload")
    185 
    186 (unittest (enscript-make-pathname "bar" "~/bin/xload")
    187           "xsvnwiki-enscript/bar/xload")
    188 
    189 (unittest (enscript-make-pathname "bar" "xload.may-there")
    190           "xsvnwiki-enscript/bar/xload-may-there")
    191 
    192 (unittest (enscript-make-pathname "bar" "xload" "application/x-scheme")
    193           "xsvnwiki-enscript/bar/xload.scm")
    194198
    195199(define (enscript-update-notify env)
Note: See TracChangeset for help on using the changeset viewer.