summaryrefslogtreecommitdiff
path: root/tests/utils.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2022-01-26 08:08:34 -0500
committerDavid Thompson <dthompson2@worcester.edu>2022-01-26 08:09:36 -0500
commit77dd14980881d9b659e23643eab5fe2ce75efe6a (patch)
treeb77293d4c90f15b467196da80adc6256803ccf7b /tests/utils.scm
parent33d1833652d79f2df0f9a469e1e88d579603f022 (diff)
Fix test suite.v0.2.6
Diffstat (limited to 'tests/utils.scm')
-rw-r--r--tests/utils.scm99
1 files changed, 47 insertions, 52 deletions
diff --git a/tests/utils.scm b/tests/utils.scm
index c2fc55b..c140520 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -1,5 +1,5 @@
;;; Haunt --- Static site generator for GNU Guile
-;;; Copyright © 2015 David Thompson <davet@gnu.org>
+;;; Copyright © 2015, 2022 David Thompson <davet@gnu.org>
;;;
;;; This file is part of Haunt.
;;;
@@ -17,70 +17,65 @@
;;; along with Haunt. If not, see <http://www.gnu.org/licenses/>.
(define-module (test-utils)
+ #:use-module (haunt utils)
#:use-module (srfi srfi-19)
#:use-module (srfi srfi-64)
- #:use-module (haunt utils))
+ #:use-module (tests helper))
-(test-begin "utils")
+(with-tests "utils"
+ (test-equal "flatten, all"
+ '(1 2 3 4 5 6)
+ (flatten '(1 (2 3 (4) (5 (6))))))
-(test-equal "flatten, all"
- '(1 2 3 4 5 6)
- (flatten '(1 (2 3 (4) (5 (6))))))
+ (test-equal "flatten, limited depth"
+ '(1 2 3 4 5 (6))
+ (flatten '(1 (2 3 (4) (5 (6)))) 2))
-(test-equal "flatten, limited depth"
- '(1 2 3 4 5 (6))
- (flatten '(1 (2 3 (4) (5 (6)))) 2))
+ (test-equal "flat-map"
+ '(5 7 9)
+ (flat-map (compose list +) '(1 2 3) '(4 5 6)))
-(test-equal "flat-map"
- '(5 7 9)
- (flat-map (compose list +) '(1 2 3) '(4 5 6)))
+ (test-equal "string-split-at, no match"
+ '("foo")
+ (string-split-at "foo" #\z))
-(test-equal "string-split-at, no match"
- '("foo")
- (string-split-at "foo" #\z))
+ (test-equal "string-split-at, match"
+ '("foo" "bar")
+ (string-split-at "foo/bar" #\/))
-(test-equal "string-split-at, match"
- '("foo" "bar")
- (string-split-at "foo/bar" #\/))
+ (test-equal "file-name-components, empty string"
+ '()
+ (file-name-components ""))
-(test-equal "file-name-components, empty string"
- '()
- (file-name-components ""))
+ (test-equal "file-name-components, root directory"
+ '("")
+ (file-name-components "/"))
-(test-equal "file-name-components, root directory"
- '("")
- (file-name-components "/"))
+ (test-equal "file-name-components, full file name"
+ '("share" "haunt")
+ (file-name-components "/share/haunt"))
-(test-equal "file-name-components, full file name"
- '("share" "haunt")
- (file-name-components "/share/haunt"))
+ (test-equal "join-file-name-components"
+ "share/haunt/info/haunt.info"
+ (join-file-name-components '("share" "haunt" "info" "haunt.info")))
-(test-equal "join-file-name-components"
- "share/haunt/info/haunt.info"
- (join-file-name-components '("share" "haunt" "info" "haunt.info")))
+ (test-equal "absolute-file-name, already absolute"
+ "/share/haunt"
+ (absolute-file-name "/share/haunt"))
-(test-equal "absolute-file-name, already absolute"
- "/share/haunt"
- (absolute-file-name "/share/haunt"))
+ (test-equal "absolute-file-name, relative file name"
+ (string-append (getcwd) "/share/haunt")
+ (absolute-file-name "share/haunt"))
-(test-equal "absolute-file-name, relative file name"
- (string-append (getcwd) "/share/haunt")
- (absolute-file-name "share/haunt"))
+ (test-equal "take-up-to, less than n elements"
+ '(1 2 3)
+ (take-up-to 4 '(1 2 3)))
-(test-equal "take-up-to, less than n elements"
- '(1 2 3)
- (take-up-to 4 '(1 2 3)))
+ (test-equal "take-up-to, more than n elements"
+ '(1 2)
+ (take-up-to 2 '(1 2 3)))
-(test-equal "take-up-to, more than n elements"
- '(1 2)
- (take-up-to 2 '(1 2 3)))
-
-(test-equal "string->date*"
- (make-date 0 0 15 06 05 09 2015
- (date-zone-offset (string->date "2015-09-05" "~Y~m~d")))
- (string->date* "2015-09-05 06:15"))
-
-(test-end)
-
-
-(exit (zero? (test-runner-fail-count (test-runner-current))))
+ (test-equal "string->date*"
+ (make-date 0 0 15 06 05 09 2015
+ (date-zone-offset (string->date "2015-09-05" "~Y~m~d")))
+ (string->date* "2015-09-05 06:15")))