refactor & relocate unit tests
parent
d07db3750c
commit
f048dabc37
@ -1,59 +0,0 @@
|
||||
#lang racket/base
|
||||
|
||||
(require rackunit "../file.rkt" "../world.rkt" sugar)
|
||||
|
||||
(check-true (sourceish? "foo.svg"))
|
||||
(check-false (sourceish? "foo.gif"))
|
||||
|
||||
(check-true (urlish? (->path "/Users/MB/home.html")))
|
||||
(check-true (urlish? "/Users/MB/home.html?foo=bar"))
|
||||
(check-true (urlish? (->symbol "/Users/MB/home")))
|
||||
|
||||
(check-true (pathish? (->path "/Users/MB/home")))
|
||||
(check-true (pathish? "/Users/MB/home"))
|
||||
(check-true (pathish? (->symbol "/Users/MB/home")))
|
||||
|
||||
(check-true (directories-equal? "/Users/MB/foo" "/Users/MB/foo/"))
|
||||
(check-false (directories-equal? "/Users/MB/foo" "Users/MB/foo"))
|
||||
|
||||
(check-equal? (get-enclosing-dir "/Users/MB/foo.txt") (->path "/Users/MB/"))
|
||||
(check-equal? (get-enclosing-dir "/Users/MB/foo/") (->path "/Users/MB/"))
|
||||
|
||||
(check-true (has-binary-ext? "foo.MP3"))
|
||||
(check-false (has-binary-ext? "foo.py"))
|
||||
|
||||
(check-true (preproc-source? "foo.pp"))
|
||||
(check-false (preproc-source? "foo.bar"))
|
||||
(check-false (preproc-source? #f))
|
||||
|
||||
|
||||
(check-true (pagetree-source? (format "foo.~a" world:pagetree-source-ext)))
|
||||
(check-false (pagetree-source? (format "~a.foo" world:pagetree-source-ext)))
|
||||
(check-false (pagetree-source? #f))
|
||||
|
||||
(check-true (markup-source? "foo.pm"))
|
||||
(check-false (markup-source? "foo.p"))
|
||||
(check-false (markup-source? #f))
|
||||
|
||||
(check-true (template-source? "foo.html.pt"))
|
||||
(check-false (template-source? "foo.html"))
|
||||
(check-false (template-source? #f))
|
||||
|
||||
|
||||
|
||||
(check-equal? (->preproc-source-path (->path "foo.pp")) (->path "foo.pp"))
|
||||
(check-equal? (->preproc-source-path (->path "foo.html")) (->path "foo.html.pp"))
|
||||
(check-equal? (->preproc-source-path "foo") (->path "foo.pp"))
|
||||
(check-equal? (->preproc-source-path 'foo) (->path "foo.pp"))
|
||||
|
||||
(check-equal? (->output-path (->path "foo.pmap")) (->path "foo.pmap"))
|
||||
(check-equal? (->output-path "foo.html") (->path "foo.html"))
|
||||
(check-equal? (->output-path 'foo.html.p) (->path "foo.html"))
|
||||
(check-equal? (->output-path (->path "/Users/mb/git/foo.html.p")) (->path "/Users/mb/git/foo.html"))
|
||||
(check-equal? (->output-path "foo.xml.p") (->path "foo.xml"))
|
||||
(check-equal? (->output-path 'foo.barml.p) (->path "foo.barml"))
|
||||
|
||||
(check-equal? (->markup-source-path (->path "foo.pm")) (->path "foo.pm"))
|
||||
(check-equal? (->markup-source-path (->path "foo.html")) (->path "foo.html.pm"))
|
||||
(check-equal? (->markup-source-path "foo") (->path "foo.pm"))
|
||||
(check-equal? (->markup-source-path 'foo) (->path "foo.pm"))
|
@ -1,61 +0,0 @@
|
||||
#lang racket/base
|
||||
(require rackunit)
|
||||
(require "../pagetree.rkt" "../world.rkt")
|
||||
|
||||
|
||||
(check-false (pagenode? "foo-bar"))
|
||||
(check-false (pagenode? "Foo_Bar_0123"))
|
||||
(check-true (pagenode? 'foo-bar))
|
||||
(check-false (pagenode? "foo-bar.p"))
|
||||
(check-false (pagenode? "/Users/MB/foo-bar"))
|
||||
(check-false (pagenode? #f))
|
||||
(check-false (pagenode? ""))
|
||||
(check-false (pagenode? " "))
|
||||
|
||||
(check-true (pagetree? '(foo)))
|
||||
(check-true (pagetree? '(foo (hee))))
|
||||
(check-true (pagetree? '(foo (hee (uncle foo)))))
|
||||
(check-false (pagetree? '(foo (hee hee (uncle foo)))))
|
||||
|
||||
|
||||
(define test-pagetree `(pagetree-main foo bar (one (two three))))
|
||||
;(define test-pagetree (pagetree-root->pagetree test-pagetree-main))
|
||||
(check-equal? (parent 'three test-pagetree) 'two)
|
||||
(check-equal? (parent "three" test-pagetree) 'two)
|
||||
(check-false (parent #f test-pagetree))
|
||||
(check-false (parent 'nonexistent-name test-pagetree))
|
||||
|
||||
|
||||
(check-equal? (children 'one test-pagetree) '(two))
|
||||
(check-equal? (children 'two test-pagetree) '(three))
|
||||
(check-false (children 'three test-pagetree))
|
||||
(check-false (children #f test-pagetree))
|
||||
(check-false (children 'fooburger test-pagetree))
|
||||
|
||||
(check-equal? (siblings 'one test-pagetree) '(foo bar one))
|
||||
(check-equal? (siblings 'foo test-pagetree) '(foo bar one))
|
||||
(check-equal? (siblings 'two test-pagetree) '(two))
|
||||
(check-false (siblings #f test-pagetree))
|
||||
(check-false (siblings 'invalid-key test-pagetree))
|
||||
|
||||
(check-equal? (previous* 'one test-pagetree) '(foo bar))
|
||||
(check-equal? (previous* 'three test-pagetree) '(foo bar one two))
|
||||
(check-false (previous* 'foo test-pagetree))
|
||||
|
||||
(check-equal? (previous 'one test-pagetree) 'bar)
|
||||
(check-equal? (previous 'three test-pagetree) 'two)
|
||||
(check-false (previous 'foo test-pagetree))
|
||||
|
||||
(check-equal? (next 'foo test-pagetree) 'bar)
|
||||
(check-equal? (next 'one test-pagetree) 'two)
|
||||
(check-false (next 'three test-pagetree))
|
||||
|
||||
(check-equal? (pagetree->list test-pagetree) '(foo bar one two three))
|
||||
|
||||
|
||||
(let ([sample-main `(world:pollen-tree-root-name foo bar (one (two three)))])
|
||||
(check-equal? sample-main
|
||||
`(world:pollen-tree-root-name foo bar (one (two three)))))
|
||||
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
#lang racket/base
|
||||
(require rackunit racket/runtime-path)
|
||||
(require "../render.rkt")
|
||||
(require/expose "../render.rkt" (modification-date-hash make-mod-dates-key path->mod-date-value store-render-in-modification-dates modification-date-expired?))
|
||||
|
||||
|
||||
(check-pred hash? modification-date-hash)
|
||||
|
||||
(define-runtime-path sample-dir "samples")
|
||||
(define samples (parameterize ([current-directory sample-dir])
|
||||
(map path->complete-path (directory-list "."))))
|
||||
(define-values (sample-01 sample-02 sample-03) (apply values samples))
|
||||
|
||||
(check-equal? (make-mod-dates-key samples) samples)
|
||||
|
||||
(check-false (path->mod-date-value (path->complete-path "garbage-path.zzz")))
|
||||
(check-equal? (path->mod-date-value sample-01) (file-or-directory-modify-seconds sample-01))
|
||||
|
||||
(check-equal? (store-render-in-modification-dates sample-01 sample-02 sample-03) (void))
|
||||
(check-true (hash-has-key? modification-date-hash (list sample-01 sample-02 sample-03)))
|
||||
|
||||
(check-true (modification-date-expired? sample-01)) ; because key hasn't been stored
|
||||
(check-false (apply modification-date-expired? samples)) ; because files weren't changed
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
#lang racket/base
|
||||
(require rackunit)
|
||||
(require "../template.rkt")
|
||||
|
||||
(define tx '(root (p "hello")))
|
||||
|
||||
(check-equal? (->html tx) "<root><p>hello</p></root>")
|
||||
(check-equal? (->html #:tag 'brennan tx) "<brennan><p>hello</p></brennan>")
|
||||
(check-equal? (->html #:attrs '((id "dale")) tx) "<root id=\"dale\"><p>hello</p></root>")
|
||||
(check-equal? (->html #:splice #t tx) "<p>hello</p>")
|
||||
(check-equal? (->html #:tag 'brennan #:attrs '((id "dale")) tx) "<brennan id=\"dale\"><p>hello</p></brennan>")
|
||||
(check-equal? (->html #:tag 'brennan #:attrs '((id "dale")) #:splice #t tx) "<p>hello</p>")
|
||||
|
||||
(define x "hello")
|
||||
|
||||
(check-equal? (->html x) "hello")
|
||||
(check-equal? (->html #:tag 'brennan x) "<brennan>hello</brennan>")
|
||||
(check-exn exn:fail? (λ() (->html #:attrs '((id "dale")) x) "hello")) ;; won't work without tag
|
||||
(check-equal? (->html #:splice #t x) "hello")
|
||||
(check-equal? (->html #:tag 'brennan #:attrs '((id "dale")) x) "<brennan id=\"dale\">hello</brennan>")
|
||||
(check-equal? (->html #:tag 'brennan #:attrs '((id "dale")) #:splice #t x) "hello")
|
||||
|
||||
|
||||
(check-equal? (select 'key '#hash((key . "value"))) "value")
|
||||
(check-false (select 'absent-key '#hash((key . "value"))))
|
||||
|
||||
(let ([metas '#hash((key . "value"))])
|
||||
(check-equal? (select 'key metas) "value")
|
||||
(check-false (select 'absent-key metas))
|
||||
(check-equal? (select-from-metas 'key metas) "value")
|
||||
(check-false (select-from-metas 'absent-key metas)))
|
||||
|
||||
(check-equal? (select 'key '(root (key "value"))) "value")
|
||||
(check-false (select 'absent-key '(root (key "value"))))
|
||||
(check-equal? (select-from-doc 'key '(root (key "value"))) '("value"))
|
||||
(check-false (select-from-doc 'absent-key '(root (key "value"))))
|
||||
|
||||
(let ([doc '(root (key "value"))])
|
||||
(check-equal? (select 'key doc) "value")
|
||||
(check-false (select 'absent-key doc))
|
||||
(check-equal? (select-from-doc 'key doc) '("value"))
|
||||
(check-false (select-from-doc 'absent-key doc)))
|
Loading…
Reference in New Issue