aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/base64.scm6
-rw-r--r--tests/cpp.scm4
-rw-r--r--tests/datetime-compare.scm5
-rw-r--r--tests/datetime-util.scm6
-rw-r--r--tests/datetime.scm5
-rwxr-xr-xtests/display2
-rw-r--r--tests/let.scm4
-rw-r--r--tests/param.scm5
-rw-r--r--tests/recurrence-advanced.scm (renamed from tests/recurrence.scm)15
-rw-r--r--tests/recurrence-id.scm30
-rw-r--r--tests/recurrence-simple.scm (renamed from tests/recurring.scm)84
-rw-r--r--tests/rrule-parse.scm24
-rwxr-xr-xtests/run-tests.scm7
-rw-r--r--tests/server.scm23
-rw-r--r--tests/srfi-41-util.scm5
-rw-r--r--[-rwxr-xr-x]tests/termios.scm6
-rw-r--r--tests/tz.scm8
-rw-r--r--tests/util.scm4
-rw-r--r--tests/vcomponent-control.scm4
-rw-r--r--tests/vcomponent-datetime.scm14
-rw-r--r--tests/vcomponent.scm4
-rw-r--r--tests/web-server.scm5
-rw-r--r--tests/xcal.scm5
23 files changed, 205 insertions, 70 deletions
diff --git a/tests/base64.scm b/tests/base64.scm
index b0bb992a..59a8784c 100644
--- a/tests/base64.scm
+++ b/tests/base64.scm
@@ -1,6 +1,10 @@
+;;; Commentary:
+;; Test that Base64 encoding and decoding works
+;; Examples from RFC4648
+;;; Code:
+
(((base64) base64encode base64decode))
-;; Examples from RFC4648
(test-equal "" (base64encode ""))
(test-equal "Zg==" (base64encode "f"))
diff --git a/tests/cpp.scm b/tests/cpp.scm
index d83ba554..84bd4b92 100644
--- a/tests/cpp.scm
+++ b/tests/cpp.scm
@@ -1,3 +1,7 @@
+;;; Commentary:
+;; Tests my parser for a subset of the C programming language.
+;;; Code:
+
(((c lex) lex)
((c parse) parse-lexeme-tree))
diff --git a/tests/datetime-compare.scm b/tests/datetime-compare.scm
index 649dc59f..f2585f46 100644
--- a/tests/datetime-compare.scm
+++ b/tests/datetime-compare.scm
@@ -1,3 +1,8 @@
+;;; Commentary:
+;; Tests that all ordering predicates for dates,
+;; times, and datetimes hold.
+;;; Code:
+
(((datetime)
date
datetime time
diff --git a/tests/datetime-util.scm b/tests/datetime-util.scm
index 123229c7..28317676 100644
--- a/tests/datetime-util.scm
+++ b/tests/datetime-util.scm
@@ -1,3 +1,9 @@
+;;; Commentary:
+;; Tests timespan overlaps and month-streams.
+;; Separate from tests/datetime.scm since
+;; (datetime util) originally was its own module.
+;;; Code:
+
(((datetime) date time datetime
month-stream in-date-range? timespan-overlaps?)
((srfi srfi-41) stream->list stream-take
diff --git a/tests/datetime.scm b/tests/datetime.scm
index 83750472..5bf2df6d 100644
--- a/tests/datetime.scm
+++ b/tests/datetime.scm
@@ -1,3 +1,8 @@
+;;; Commentary:
+;; Tests date, time, and datetime creation,
+;; (output) formatting, and arithmetic.
+;;; Code:
+
(((datetime) date+ date-
time+ time-
year month day
diff --git a/tests/display b/tests/display
new file mode 100755
index 00000000..e58288a2
--- /dev/null
+++ b/tests/display
@@ -0,0 +1,2 @@
+#!/bin/bash
+guild display-commentary *.scm | sed -e 's/^ / /' -e 's/^\S/\n&/g'
diff --git a/tests/let.scm b/tests/let.scm
index 82919b49..81a34131 100644
--- a/tests/let.scm
+++ b/tests/let.scm
@@ -1,3 +1,7 @@
+;;; Commentary:
+;; Tests my custom let*.
+;;; Code:
+
(((calp util) let*)
((guile) set!))
diff --git a/tests/param.scm b/tests/param.scm
index 0c4190dd..23704948 100644
--- a/tests/param.scm
+++ b/tests/param.scm
@@ -1,3 +1,8 @@
+;;; Commentary:
+;; Checks that parameters (1) are correctly parsed and stored.
+;; (1): 'A', and 'B' in the line "KEY;A=1;B=2:Some text"
+;;; Code:
+
(((vcomponent base) param prop* parameters)
((vcomponent parse) parse-calendar)
((calp util) sort*))
diff --git a/tests/recurrence.scm b/tests/recurrence-advanced.scm
index 6ced6af0..c2242c19 100644
--- a/tests/recurrence.scm
+++ b/tests/recurrence-advanced.scm
@@ -1,9 +1,20 @@
;;; Commentary:
+;; Tests of recurrence rule generation with focus on correct instances
+;; being generated. For tests of basic recurrence functionallity, see
+;; recurrence-simple.scm.
+;;
+;; This file also tests format-recurrence-rule, which checks that human
+;; readable representations of the RRULES work.
+;;
+;; Also contains the tests for EXDATE.
+;;
+;; Most examples copied from RFC5545, some home written.
+;;; Code:
+
;; The human readable tests are expected to fail with any change to the
;; text creator. Proof-read them manually, and update the test cases
;; to match. `x-summary' used for target string. Target strings should
;; be in swedish.
-;;; Code:
(((vcomponent recurrence parse) parse-recurrence-rule)
((vcomponent recurrence generate) generate-recurrence-set)
@@ -16,8 +27,6 @@
((srfi srfi-41) stream->list)
((srfi srfi-88) keyword->string))
-;; Examples copied from RFC5545
-
(define (run-test comp)
(test-equal (string-append "RSET: " (prop comp 'SUMMARY))
diff --git a/tests/recurrence-id.scm b/tests/recurrence-id.scm
deleted file mode 100644
index 601b0f71..00000000
--- a/tests/recurrence-id.scm
+++ /dev/null
@@ -1,30 +0,0 @@
-(((srfi srfi-41) stream->list)
- ((vcomponent) parse-calendar)
- ((vcomponent recurrence) generate-recurrence-set)
- ((guile) format)
- )
-
-(define uid (symbol->string (gensym "areallyuniqueid")))
-
-(define ev
- (call-with-input-string
- (format #f "BEGIN:VCALENDAR
-BEGIN:VEVENT
-SUMMARY:Changing type on Recurrence-id.
-UID:~a
-DTSTART;VALUE=DATE:20090127
-END:VEVENT
-BEGIN:VEVENT
-UID:~a
-SUMMARY:Changing type on Recurrence-id.
-DTSTART;TZID=Europe/Stockholm:20100127T120000
-RECURRENCE-ID;VALUE=DATE:20100127
-SUMMARY:This instance only has a time component
-END:VEVENT
-END:VCALENDAR"
- uid uid)
- parse-calendar))
-
-
-(test-assert "Changing type on Recurrence id."
- (stream->list 10 (generate-recurrence-set ev)))
diff --git a/tests/recurring.scm b/tests/recurrence-simple.scm
index a3f98027..9c78977b 100644
--- a/tests/recurring.scm
+++ b/tests/recurrence-simple.scm
@@ -1,9 +1,43 @@
+;;; Commentary:
+;; Simples tests of recurrence system, ensuring that all parsers and
+;; basic generators work. Some more fully-featured tests are here, but
+;; most are instead in recurrence-advanced.scm.
+;;; Code:
+
(((srfi srfi-41) stream-take stream-map stream->list stream-car)
- ((datetime) day-stream)
+ ((datetime) day-stream mon)
((vcomponent base) extract prop)
+ ((calp util exceptions) warnings-are-errors warning-handler)
+ ((guile) format)
+
((vcomponent) parse-calendar)
- ((vcomponent recurrence) generate-recurrence-set))
+ ((vcomponent recurrence)
+ parse-recurrence-rule
+ make-recur-rule
+ generate-recurrence-set))
+
+;;; Test that basic parsing or recurrence rules work.
+
+(test-equal (make-recur-rule freq: 'HOURLY wkst: mon interval: 1)
+ (parse-recurrence-rule "FREQ=HOURLY"))
+
+(test-equal (make-recur-rule freq: 'HOURLY count: 3 interval: 1 wkst: mon)
+ (parse-recurrence-rule "FREQ=HOURLY;COUNT=3"))
+
+;;; Test that recurrence rule parsing fails where appropriate
+
+(parameterize ((warnings-are-errors #t)
+ (warning-handler identity)) ; silence warnings
+ (test-error "Invalid FREQ" 'warning
+ (parse-recurrence-rule "FREQ=ERR;COUNT=3"))
+
+ (test-error "Negative COUNT" 'warning
+ (parse-recurrence-rule "FREQ=HOURLY;COUNT=-1"))
+
+ (test-error "Invalid COUNT"
+ 'wrong-type-argument
+ (parse-recurrence-rule "FREQ=HOURLY;COUNT=err")) )
;;; Test that basic recurrence works
;;; also see the neighbour test file recurrence.scm for more tests.
@@ -158,3 +192,49 @@ END:VEVENT"
(test-assert "Full test"
(stream-car (generate-recurrence-set ev)))
+
+;;; Tests that exceptions (in the recurrence-id meaning)
+;;; in recurrence sets are handled correctly.
+;;; TODO Is however far from done.
+
+(define uid (symbol->string (gensym "areallyuniqueid")))
+
+;; TODO standardize vcomponents for tests as xcal, for example:
+`(vcalendar
+ (children
+ (vevent
+ (properties
+ (summary (text "Changing type on Recurrence-id."))
+ (uid (text ,uid))
+ (dtstart (date "20090127"))))
+ (vevent
+ (properties
+ (summary (text "Changing type on Recurrence-id."))
+ (uid (text ,uid))
+ (dtstart (params (TZID "Europe/Stockholm"))
+ (date-time "20100127T120000"))
+ (recurrence-id (date "20100127"))
+ (summary "This instance only has a time component")))))
+
+(define ev
+ (call-with-input-string
+ (format #f "BEGIN:VCALENDAR
+BEGIN:VEVENT
+SUMMARY:Changing type on Recurrence-id.
+UID:~a
+DTSTART;VALUE=DATE:20090127
+END:VEVENT
+BEGIN:VEVENT
+UID:~a
+SUMMARY:Changing type on Recurrence-id.
+DTSTART;TZID=Europe/Stockholm:20100127T120000
+RECURRENCE-ID;VALUE=DATE:20100127
+SUMMARY:This instance only has a time component
+END:VEVENT
+END:VCALENDAR"
+ uid uid)
+ parse-calendar))
+
+
+(test-assert "Changing type on Recurrence id."
+ (stream->list 10 (generate-recurrence-set ev)))
diff --git a/tests/rrule-parse.scm b/tests/rrule-parse.scm
deleted file mode 100644
index b7a851a0..00000000
--- a/tests/rrule-parse.scm
+++ /dev/null
@@ -1,24 +0,0 @@
-(((vcomponent recurrence parse)
- parse-recurrence-rule)
- ((vcomponent recurrence) make-recur-rule)
- ((datetime) mon)
- ((calp util exceptions) warnings-are-errors warning-handler)
- )
-
-(test-equal (make-recur-rule freq: 'HOURLY wkst: mon interval: 1)
- (parse-recurrence-rule "FREQ=HOURLY"))
-
-(test-equal (make-recur-rule freq: 'HOURLY count: 3 interval: 1 wkst: mon)
- (parse-recurrence-rule "FREQ=HOURLY;COUNT=3"))
-
-(parameterize ((warnings-are-errors #t)
- (warning-handler identity)) ; silence warnings
- (test-error "Invalid FREQ" 'warning
- (parse-recurrence-rule "FREQ=ERR;COUNT=3"))
-
- (test-error "Negative COUNT" 'warning
- (parse-recurrence-rule "FREQ=HOURLY;COUNT=-1"))
-
- (test-error "Invalid COUNT"
- 'wrong-type-argument
- (parse-recurrence-rule "FREQ=HOURLY;COUNT=err")) )
diff --git a/tests/run-tests.scm b/tests/run-tests.scm
index 670a1784..4060a170 100755
--- a/tests/run-tests.scm
+++ b/tests/run-tests.scm
@@ -2,6 +2,13 @@
-s
!#
+;;; Commentary:
+;; Not a test, but a script that runs tests.
+;; Assumes that all other .scm files in this directory are test files,
+;; and should thereby follow the test-file syntax.
+;; TODO document the testfile syntax.
+;;; Code:
+
(eval-when (compile load)
(define here (dirname (current-filename))))
diff --git a/tests/server.scm b/tests/server.scm
index a9cb870e..d21c11da 100644
--- a/tests/server.scm
+++ b/tests/server.scm
@@ -1,6 +1,21 @@
-(((web http make-routes) parse-endpoint-string))
+;;; Commentary:
+;; Tests parse-endpoint-string, used for defining server routes.
+;;; Code:
-(test-assert (parse-endpoint-string "/static/:dir/:file"))
-;; => "/static/([^/]+)/([^/]+)"
-;; => (dir file)
+(((web http make-routes) parse-endpoint-string)
+ ((calp util) let*))
+(test-assert "Check that parsing doesn't crash"
+ (parse-endpoint-string "/static/:dir/:file"))
+
+;; Checks that parsing produces correct results
+(let* ((path args (parse-endpoint-string "/static/:dir/:file")))
+ (test-equal "/static/([^/.]+)/([^/.]+)" path)
+ (test-equal '(dir file) args))
+
+
+;; Checks that parsing with custom regex works
+;; along with literal periods.
+(let* ((path args (parse-endpoint-string "/static/:filename{.*}.:ext")))
+ (test-equal "/static/(.*)\\.([^/.]+)" path)
+ (test-equal '(filename ext) args))
diff --git a/tests/srfi-41-util.scm b/tests/srfi-41-util.scm
index 61bce71e..3c2c3f0f 100644
--- a/tests/srfi-41-util.scm
+++ b/tests/srfi-41-util.scm
@@ -1,3 +1,8 @@
+;;; Commentary:
+;; Tests (srfi srfi-41 util).
+;; Currently only tests stream-paginate.
+;;; Code:
+
(((srfi srfi-41 util) stream-paginate)
((srfi srfi-41) stream->list stream-ref stream-from
stream-filter stream-car stream)
diff --git a/tests/termios.scm b/tests/termios.scm
index 214a12a0..c0cb4323 100755..100644
--- a/tests/termios.scm
+++ b/tests/termios.scm
@@ -1,10 +1,8 @@
;;; Commentary:
-
;; Tests that my termios function works, at least somewhat.
-;; Note that this actually modifies the terminal it's run on, and might fail if
-;; the terminal doesn't support the wanted modes. See termios(3).
+;; Note that this actually modifies the terminal it's run on, and might fail
+;; if the terminal doesn't support the wanted modes. See termios(3).
;; It might also leave the terminal in a broken state if exited prematurely.
-
;;; Code:
(((calp util) set!)
diff --git a/tests/tz.scm b/tests/tz.scm
index 8ccd636d..147f0807 100644
--- a/tests/tz.scm
+++ b/tests/tz.scm
@@ -1,3 +1,11 @@
+;;; Commentary:
+;; Tests that datetime->unix-time correctly converts between Olssen
+;; timezone definitions (e.g. Europe/Stockholm), into correct times
+;; and offsets (in unix time).
+;; Also indirectly tests the Zone Info Compiler (datetime zic), since
+;; the zoneinfo comes from there.
+;;; Code:
+
(((datetime)
parse-ics-datetime
datetime date time
diff --git a/tests/util.scm b/tests/util.scm
index f917b5ce..ed5abfd1 100644
--- a/tests/util.scm
+++ b/tests/util.scm
@@ -1,3 +1,7 @@
+;;; Commentary:
+;; Checks some prodecuders from (calp util)
+;;; Code:
+
(((calp util) filter-sorted set/r!))
(test-equal "Filter sorted"
diff --git a/tests/vcomponent-control.scm b/tests/vcomponent-control.scm
index 8cc87a0a..2ee4c243 100644
--- a/tests/vcomponent-control.scm
+++ b/tests/vcomponent-control.scm
@@ -1,3 +1,7 @@
+;;; Commentary:
+;; Tests that with-replaced-properties work.
+;;; Code:
+
(((vcomponent control) with-replaced-properties)
((vcomponent) parse-calendar)
((vcomponent base) prop))
diff --git a/tests/vcomponent-datetime.scm b/tests/vcomponent-datetime.scm
index f7bb00f4..0bc584f6 100644
--- a/tests/vcomponent-datetime.scm
+++ b/tests/vcomponent-datetime.scm
@@ -1,3 +1,8 @@
+;;; Commentary:
+;; Tests that event-clamping (checking how long part of an event
+;; overlaps another time span) works.
+;;; Code:
+
(((datetime)
date time
datetime)
@@ -13,10 +18,15 @@ DTEND:20200401T100000
END:VEVENT"
parse-calendar))
+;; |-----------------| test interval
+;; |----------| event interval
(test-equal "Correct clamping"
- (datetime time: (time hour: 7))
- (event-length/clamped #2020-03-23 #2020-03-29 ev))
+ (datetime time: (time hour: 7)) ; 2020-03-29T17:00 - 2020-03-30T00:00
+ (event-length/clamped
+ #2020-03-23 ; a time way before the start of the event
+ #2020-03-29 ; a time slightly after the end of the event
+ ev))
(define utc-ev (call-with-input-string
"BEGIN:VEVENT
diff --git a/tests/vcomponent.scm b/tests/vcomponent.scm
index 0d81ab0e..15c83845 100644
--- a/tests/vcomponent.scm
+++ b/tests/vcomponent.scm
@@ -1,3 +1,7 @@
+;;; Commentary:
+;; Test that vcomponent parsing works at all.
+;;; Code:
+
(((vcomponent base) prop)
((vcomponent) parse-calendar))
diff --git a/tests/web-server.scm b/tests/web-server.scm
index 6b315319..bce05d0e 100644
--- a/tests/web-server.scm
+++ b/tests/web-server.scm
@@ -1,3 +1,8 @@
+;;; Commentary:
+;; Checks that HTTP server can start correctly, and that at least some
+;; endpoints return correct information.
+;;; Code:
+
(((calp server routes) make-make-routes)
((web server) run-server)
((ice-9 threads) call-with-new-thread cancel-thread)
diff --git a/tests/xcal.scm b/tests/xcal.scm
index 1748cba3..babb2218 100644
--- a/tests/xcal.scm
+++ b/tests/xcal.scm
@@ -1,3 +1,8 @@
+;;; Commentary:
+;; Basic tests of xcal convertion.
+;; Currently only checks that events survive a round trip.
+;;; Code:
+
(((vcomponent xcal parse) sxcal->vcomponent)
((vcomponent xcal output) vcomponent->sxcal)
((vcomponent ical parse) parse-calendar)